1

A usefull function, everyone should have near by. May requires some optimisations.

/// <summary>
/// DoEs tHiS To tHe pRoViDeD StRiNg. StArTs aLwAyS WiTh a cApItAl
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string DoThIsToThEtExT(string s)
{
var array = s.ToCharArray();
Parallel.For(0, s.Length, (index) =>
{
if (index % 2 == 0)
{
array[index] = array[index].ToString().ToUpper()[0];
}
else
{
array[index] = array[index].ToString().ToLower()[0];
}
});
return new string(array);
}

Comments
  • 2
    @highlight

    /// <summary>
    /// DoEs tHiS To tHe pRoViDeD StRiNg. StArTs aLwAyS WiTh a cApItAl
    /// </summary>
    /// <param name="s"></param>
    /// <returns></returns>
    public static string DoThIsToThEtExT(string s)
    {
    var array = s.ToCharArray();
    Parallel.For(0, s.Length, (index) =>
    {
    if (index % 2 == 0)
    {
    array[index] = array[index].ToString().ToUpper()[0];
    }
    else
    {
    array[index] = array[index].ToString().ToLower()[0];
    }
    });
    return new string(array);
    }
  • 0
  • 0
    @cabbybaby thanks, too bad it doesn't work directly inside rant
Add Comment