Login

Username:

Password: 

Join us Now |  Forgot Password? | Forgot UserName?

C#

Learn step by step



Variables

A variable, in C#, refers to a location in memory in which an application can store its data. Variables are used to store the result of calculations and hold the values that can change during the execution of a program. Variables are also used to place and retrieve the data forms an expression.
Syntax
<data type> <name>;


using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string firstName = "jai";
string lastName = "veeru";

Console.WriteLine("Name: " + firstName + " " + lastName);

Console.WriteLine("Please enter a new first name:");
firstName = Console.ReadLine();

Console.WriteLine("New name: " + firstName + " " + lastName);

Console.ReadLine();
}
}
}

Output

New name: jai veeru


Related Videos