Showing posts with label C# Programming Examples of Variables and Data types. Show all posts
Showing posts with label C# Programming Examples of Variables and Data types. Show all posts

Tuesday, September 2, 2014

C# Programming Examples of Variables and Data types




using System;
 
namespace Examples
{
  class Program
   {
     static void Main(string[] args)
      {
        string name;
        string city;
        sbyte age;
        int pin;
 
        // \n is used for line-break
        Console.WriteLine("Enter your name\n");
        name = Console.ReadLine();
 
        Console.WriteLine("Enter Your City\n");
        city = Console.ReadLine();
 
        Console.WriteLine("Enter your age\n");
        age = sbyte.Parse(Console.ReadLine());
 
        Console.WriteLine("Enter your pin\n");
        pin = Int32.Parse(Console.ReadLine());
 
        // Printing message to console
        //formatting output
        Console.WriteLine("=============="); 
        Console.WriteLine("Your Complete Address:");
        Console.WriteLine("============\n");
 
        Console.WriteLine("Name = {0}", name);
        Console.WriteLine("City = {0}", city);
        Console.WriteLine("Age = {0}", age);
        Console.WriteLine("Pin = {0}", pin);
        
Console.WriteLine("===============");
 
        Console.ReadLine();
      }
   }
}
O/P:

Enter your Name :Naresh
Enter Your City :Wgl
Enter Your age  :23
Enter Your Pin  :506164

=============================
Your Complete Address:
=============================
your Name :Naresh
Your City :Wgl
Your age  :23
Your Pin  :506164