This is a simple code snippet for reversing a string without using the
Reverse
function. For example, we have a string "Asp Dot Net"; without using a function, we can reverse it using the code snippet below. Code is given in both C#. This will be helpful to beginners. If you have any queries, please feel free to ask me.static void ReverseString(string str)
{
Console.Write("Original String: {0}", str);
Console.Write(Environment.NewLine);
Console.Write("-----------------------");
Console.Write(Environment.NewLine);
StringBuilder sb = new StringBuilder();
for (int i = str.Length - 1; i >= 0; i--)
{
sb.Append(str[i]);
}
Console.Write("After Reverse String: {0}", sb.ToString());
Console.ReadKey();
}
static void Main(string[] args)
{
ReverseString("Asp Dot Net");
}
Nice information................
ReplyDelete