Full width home advertisement

Post Page Advertisement [Top]

declare a variable in c#
sum of two numbers in c# .getting value from user side.
Let's start on this page we will see how to declare a variable and in c# and after declaring variable well do the sum of 2  numbers.


Step 1- Create an empty project as we do at hello world blog if you didn't how to create empty console application then plz watch my last blog.

Step 2- write the below code in the main section.which is highlighted with red color.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please Enter value of a");
            int a =Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please Enter value of b");
            int b = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(a + b);
            Console.ReadLine();
        }
    }
}

Output..

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib