Test yazım
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
SortedDictionary<int, List<string>> dic = new SortedDictionary<int, List<string>>(); string metin = "erkan bir celal a b cc"; string[] arr = metin.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var sozcuk in arr) { int key = sozcuk.Length; if (!dic.ContainsKey(key)) { dic.Add(sozcuk.Length, new List<string>()); dic[sozcuk.Length].Add(sozcuk); } else { dic[key].Add(sozcuk); } } string result = ""; foreach (var item in dic) { foreach (var value in item.Value) { result += " " + value; } } result = result.Trim().Substring(0, 1).ToUpper() + result.Trim().Substring(1,result.Length-2).ToLower(); result =result+ "."; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
/* ==Scripting Parameters== Source Server Version : SQL Server 2012 (11.0.6518) Source Database Engine Edition : Microsoft SQL Server Standard Edition Source Database Engine Type : Standalone SQL Server Target Server Version : SQL Server 2017 Target Database Engine Edition : Microsoft SQL Server Standard Edition Target Database Engine Type : Standalone SQL Server */ USE [orman] GO /****** Object: StoredProcedure [dbo].[DetectDirtyFeatures] Script Date: 8.11.2017 11:18:53 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER PROCEDURE [dbo].[DetectDirtyFeatures] -- Add the parameters for the stored procedure here @featuresId bigint, @featuresStaticId bigint, @delaySecond int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here DECLARE @Idcounter int =0,@valueCounter bigint = 0,@Id bigint =0,@pagesize int =1,@startId bigint=0 DECLARE @features xml SET @Idcounter=@startId-@pagesize WHILE (1 = 1) BEGIN SET @Idcounter += @pagesize; IF @Idcounter >= 2 BREAK DECLARE c CURSOR FOR SELECT Top (@pagesize) Id,features FROM [Orman].[dbo].[Document] where Id>@Idcounter OPEN c FETCH NEXT FROM c INTO @Id,@features WHILE (@@FETCH_STATUS=0) BEGIN DECLARE @Xsql nvarchar(max); DECLARE @retval nvarchar(max) SET @Xsql = ' Set @retvalOUT=(SELECT @feature.value(''(/features/f' + CAST(@featuresId AS nvarchar(max)) + ')[1]'',''nvarchar(max)''))' EXECUTE sp_executesql @xSql, N'@retvalOUT nvarchar(max) OUTPUT, @feature xml', @retvalOUT = @retval OUTPUT, @feature = @features IF CAST(@retval AS bigint) = @featuresStaticId BEGIN SET @valueCounter += 1 declare @returnXml xml declare @Modifysql nvarchar(300) set @Modifysql= ' Set @xmlInput.modify(''replace value of (/features/f' + CAST(@featuresId AS nvarchar(max)) + '/text())[1] with "yeni deger"''); set @xmlOut=@xmlInput' print @modifysql EXECUTE sp_executesql @modifySql, N'@xmlOut xml OUTPUT, @xmlInput xml', @xmlOut = @returnXml OUTPUT, @xmlInput = @features --SET @features.modify('replace value of (/features/f'+'8/text())[1] with "yeni deger" '); PRINT 'DocumentId='+ cast(@Id as nvarchar)+ ' FeatureId=' + CAST(@featuresId AS varchar) + ' FeatureStaticId ' + @retval select @features, @returnXml END FETCH NEXT FROM c INTO @Id,@features END DECLARE @Delay2 DATETIME = dateadd(SECOND, @delaySecond, convert(DATETIME, 0)) WAITFOR DELAY @Delay2 CLOSE c DEALLOCATE c END PRINT 'Toplam=' + CAST(@valueCounter AS varchar) END |
Son yorumlar