I am just trying to find out the reverse and length of a string. Here is the snippet of the Code:
Console.WriteLine("Please Enter your String: ");
string InputString = Console.ReadLine();
char[] String_Array = InputString.ToCharArray();
int Length = 0;
foreach (char c in String_Array)
{
Length++;
}
char[] String_Reverse = null;
for (int i = Length - 1, j = 0; Length >= 0; Length--, j++)
{
//Here is the error I am facing, Null Reference Exception
String_Reverse[j] = String_Array[i];
}
string Reverse = new string(String_Reverse);
Console.WriteLine("Length of the String " + InputString + " is :" + Length + " and Reverse of the String is :" + Reverse);
Console.ReadLine();