It-Tnejn, Jannar 21, 2008

C# String Manipulation

class Program
{//assign string variables
static void Main(string[] args)
{
string name, surname, fullName, lcasename, ucasename;
int numberofChars;
char firstNameChar, firstSurnameChar;

Console.WriteLine("Enter Name");
name = Console.ReadLine();

Console.WriteLine("Enter Surname");
surname = Console.ReadLine();

fullName = name + " " + surname;

lcasename = fullName.ToLower();
ucasename = fullName.ToUpper();
Console.WriteLine("The Name entered in LOWER case is: " + lcasename);
Console.WriteLine("The Name entered in UPPER case is: " + ucasename);

numberofChars = fullName.Length;
Console.WriteLine("The number of characters in " + fullName + " is: " + numberofChars);

firstNameChar = name[0];

firstSurnameChar = surname[0];
Console.WriteLine("The initials of " + fullName + " are: " + firstNameChar + " " + firstSurnameChar);
Console.ReadLine();
}

No comments: