Showing posts with label string reverse. Show all posts
Showing posts with label string reverse. Show all posts

19 September 2011

Reverse of a string or number in console apps

class Reverseofno
{
public static void Main()
{
Console.WriteLine("enter a no/string: ");
string a = Console.ReadLine();
for (int x = a.Length - 1; x >= 0; x--)
{
Console.Write(a[x]);
}
Console.WriteLine();
--------------------------------------------------
string bb = string.Empty;
Console.WriteLine("enter a no/string: ");
string b = Console.ReadLine();
for (int x = b.Length - 1; x >= 0; x--)
{
bb += b[x].ToString();
}
string[] bbb = new string[bb.Split(' ').Length];
for (int y = 0; y = 0; z--)
{
Console.Write(bbb[z]);
}
Console.WriteLine();
---------------------------------------------------
Console.WriteLine("enter a name: ");
string n= Console.ReadLine();
if(bbb.Contains(n+" "))
Console.WriteLine("found");
else
Console.WriteLine("not found");
Console.ReadLine();
}
}