static string RevereseStringWithoutInbuildFunc(string inputString)
{
if (string.IsNullOrEmpty(inputString))
{
throw new NullReferenceException();
}
StringBuilder strBuilder = new StringBuilder();
for (int i = inputString.Length - 1; i >= 0; i--)
{
strBuilder.Append(inputString[i]);
}
return strBuilder.ToString();
}
static string RevereseStringWithInbuildFunc(string inputString)
{
if (string.IsNullOrEmpty(inputString))
{
throw new NullReferenceException();
}
char[] inputArray = inputString.ToCharArray();
Array.Reverse(inputArray);
return new string(inputArray);
}
No comments:
Post a Comment