September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,6 @@
static string ReverseString(string input)
{
char[] inputChars = input.ToCharArray();
Array.Reverse(inputChars);
return new string(inputChars);
}

View file

@ -0,0 +1,7 @@
using System.Linq;
// ...
return new string(input.Reverse().ToArray());
// ...

View file

@ -0,0 +1,14 @@
public string ReverseElements(string s)
{
// In .NET, a text element is series of code units that is displayed as one character, and so reversing the text
// elements of the string correctly handles combining character sequences and surrogate pairs.
var elements = System.Globalization.StringInfo.GetTextElementEnumerator(s);
return string.Concat(AsEnumerable(elements).OfType<string>().Reverse());
}
// Wraps an IEnumerator, allowing it to be used as an IEnumerable.
public IEnumerable AsEnumerable(IEnumerator enumerator)
{
while (enumerator.MoveNext())
yield return enumerator.Current;
}