Code Snippet posted by:
Ubaid | Posted on: 4/24/2012 | Category:
C# Codes | Views: 985 | Status:
[Member] |
Points: 40
|
Alert Moderator
Note: Create new Console application from dotnet or simple write the following text in note paid then execute..
any way ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace palindromeExample //(this will be your project name like create new application and write the name)
{
public class Program
{
public void Palindrome(string input) //(this is a method name)
{
string getInput = input; //(take input from user )
int length = getInput.Length;
string strCmp = "";
for (int j = length-1; j>=0; j--)
{
strCmp = strCmp + getInput[j]; //(get one by one user input and reverse)
}
if (strCmp == getInput) //(check condition is palindrome or not)
{
Console.WriteLine("this is palinderome");
}
else
{
Console.WriteLine("not vlaid palindrome....");
}
Console.WriteLine(strCmp);
}
static void Main(string[] args)
{
string UsrInput = "";
Console.WriteLine("Enter the input value:\n");
UsrInput = Console.ReadLine();
if (UsrInput != "")
{
Program objPrg = new Program();
objPrg.Palindrome(UsrInput);
}
else
{
Console.WriteLine("enter value...");
}
Console.Read(); // using this line screen will not disappear..
}
}
}
Ubaid
Found interesting? Add this to: