Basic Problem

Hello World Program

using System;
namespace HelloWorldApp
{
   class Program
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}
When you run this program, it produces the following result:
Hello World
 
Note:
 
  • The first line of the program using System;
    the using keyword is used to include the System  namespace 
    in the program. 
    A program generally has multiple using statements.
  •  The next line has the namespace declaration. 
    A namespace is a collection of classes 
    
    
     

Simple Calculation 

using System;

namespace Calculation
{
    class Program
    {
        static void Main(string[] args)
        {
            int firstNumber, secondNumber;
            int sum, sub, mul, div;


            Console.Write("Enter First Number :");
            firstNumber = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Second Number:");
            secondNumber = Convert.ToInt32(Console.ReadLine());


            sum = firstNumber + secondNumber;
            sub = firstNumber - secondNumber;
            mul = firstNumber * secondNumber;
            div = firstNumber / secondNumber;


            Console.WriteLine("Sum = {0} Sub = {1} Mul = {2} Div = {3}", sum, sub, mul, div);
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment