C# : Sort

[".0s4*0|collections;datetime-format;sort",["F@eBCDEU^","OALAMLBEJC","OYOBSTUUUUTTUUUUPFGDHDADADADFOBBOBBCWCSTTUUUUTTUUUU","w.s.",".NET","Array","Dictionary","List","String","2D","Async","Console","DataTable","Dates","DateTime","Enum","File","For","Foreach","Format","IEnumerable","If","IndexOf","Lambda","LINQ","Optimization","Parse","Path","Process","Property","Random","Regex","Replace","Sort","Split","Static","Substring","Switch","Tuple","While","Reverse String."," A string can be reversed. A reversal method can be implemented in several ways. Some ways are faster than others. And some use more lines of code\u2014they are more complex to understand. We review and time one method. ","Required input, output","\n\nframework krowemarf\nexample string gnirts elpmaxe","Example."," First, there are many solutions, but this one can be done with three lines of code. The method shown in this article is based on my work with ToCharArray. It is static because it stores no state. ","ToCharArray ","tochararray","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","Based on:"," .NET 4.0\n\n","C# program that reverses strings","\n\nusing System;\n\nstatic class StringHelper\n{","\n /// <summary>\n /// Receives string and returns the string with its letters reversed.\n /// </summary>\n ","public static string ","ReverseString","(string s)\n {\n char[] arr = s.ToCharArray();\n Array.Reverse(arr);\n return new string(arr);\n }\n}\n\nclass Program\n{\n static void Main()\n {\n Console.WriteLine(StringHelper.ReverseString(","\"framework\"","));\n Console.WriteLine(StringHelper.ReverseString(","\"samuel\"","));\n Console.WriteLine(StringHelper.ReverseString(","\"example string\"","));\n }\n}\n\n","Output","\n\nkrowemarf\nleumas\ngnirts elpmaxe","The method above"," receives a string parameter, which is the string in which you wish to reverse the order of the letters. The method is static because it doesn't store state. It calls Array.Reverse to modify the order of the chars. ","Static Method ","static","Array.Reverse ","array-reverse","Control flow of method."," It copies to an array using the ToCharArray instance method on the string class. This returns the mutable char[] buffer from the string. It returns a string with the new string constructor. ","Char Array ","char-array","String Constructor ","string-constructor","Performance: ","Using ToCharArray on strings for modifications is often efficient. Many benchmarks support this statement.","Summary."," We saw a method that can receive a string and then return the string with its characters in the reverse order. It is one of many examples of using char arrays for string manipulation in the C# language. ","Note: ","The code isn't useful often. It may help for an interview question or two.","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"],"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO4AAAAvCAMAAADThAYBAAAAMFBMVEX////suOjW1tbn5+fjid3z8fSZquR4keT5+Pq1wOr32vXZ4PfK0/NPdeTj6PnkT9vNZmRwAAAFF0lEQVR4XrWZ6ZaySgxFM9QIDu//tlflIyscqgOXpfuvkmQDp5sIGfTopdT7/V5L6ZlGTBNzevF8PlNizuSZa3/QCSaGCpdp72meS6mJgFJujf4k9/uGehtURhJ73fdRdp7WOh3acFCB6tqcEJvOxiKGeeDclZdEueHhrhxQZ39JnmPS5HQ/lDnQ5bAClVWqEVBX3dVpSvtS3GhXq7e9bqv3ET3QNdh03Y0x1m0prkA3vIaG1cbzdnzqSgZds0VKoGuw6RplBl2zjX3b7iis3cEWmZyu0ZvpwifALdS1FqZrlIGuswU4CC9GN54mNdCFcewWGpNP6CZ/JyI9yq2RQQvCi6FOz7NnDtl8UEsXkV6K6RbUTStweUNdmDExiwhzwjMmcBX30ZW8DW5iecHOfwp1/ZhdVrp9ef6nm1JiFg9D9h411HVfxxI2pAochtEt0nwqkhgJzhyVOtYt3taAy5tlwLZDFumuB+omb2ts05sFwovR7eqDlcSRIBg6HIeaiYkH0gK60MF/pZehboMZ8foubbAtRlfU3yeyAdKr8gGM6eYurqdais7q+igYHcPP0ZAK4R1GN8GJg2Qkr4vGZA3Apdi8p3UdBXXxkmANDsL7sGQJvcDkYjCa08Xzb9GtIqK5EVHLKiLdpci56IrVH+rC2O6SQBu7JkF4b+Po8qfUp7X6bE2ma5Sdbh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lawpzm7hVP3TxwcFFL92lyk/IDxPYppfaP2XatebG3ext1qOhalq7nS2joV6ThSoy3KMa1Smk8xUYKcsyi1x4ZA+imaRLRUS17CiWgE0VGjg7vmmkRpSiS1pSiS1o1AWtHukspkpR+8RMp7OnFH+mykcnrNIgpIB4IHgKAAB+RAYAAAAAGAgFgoTyELBQmiiWvYELdLYW6LGnuna3zqNRFtRClElrEKUSW1EKUSW1RqBLWl04+siTLeEd2fBh3PBAYCmAEDwAYAAAAAAAAAS6ADKABNBCZQsALABulGtuHS3ijE1AlrqaiLWjUSW1SlEWtHgi0qC9ZElrGO7Lgy7AAACBgAAAAAAAAAAANAACKF7AAIWCgIHgBbkeiLaawNyPRCzWBuroiWawN1dELKg91dBa1A3V0FlQeF0BQCggAGAAAAAAAAAAAAAAAA/aAveUIAAYAAEAUABwAAAAACBgAAAAAAAAAH//2Q==)"]

["url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAACCAgMAAADasxWRAAAADFBMVEX/6Nn///+VlZX29va5ksB5AAAASElEQVR4AWPACZj/f0DmjkqOSjKtQgcLyJccZiEE9SOmP8mXHEaBMBoIo4EwGggryJccvvVKKAogTnJUclRyVHLklgmjkqOSAALWyrsxEHLDAAAAAElFTkSuQmCC)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAAByCAAAAADMwOSzAAACe0lEQVR4Xu3csY7kMAgG4Lz/86Wkp6ZAokDy6RTfodVsTDSaxPy7/uux9a0LZpkEb20YNzNVEWYmItr/hYiYWcS8Tcw2cKv8DTPtoxCzqFfC+wGXgCchYlGvgDfp9MBd/xNsIj7otL8XHwC8x14Sq04/Yine4tRvwEvP6ypqPXp+dgneY+nbaZPwHscOh7eww+HDjoL/uJ1m4D3scPjYFw8fawDxUWjw8LErFP7TB7/z0/jYFA8fB4+Il1iQh47UwF//fvrfLPV/t0WEj+52Ev5yjWc96y/MNNrdR/EX6yRZuxb3Z/Ge10lu1/MsPm9auZXFS09iL4n3DE+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