programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, September 24, 2014

C# Variables,How to declare in C#:

What is C# Variables how to declare in C#:

C# Variables:

Available is a name given to a storage area (memory) that our programs can manipulate. Each variable in C# has a specific type( variable type, or you can say data type), which determines the size and layout of the variable in  memory; the range of values that can be stored within that memory.
We have already discussed various data types. The basic value types provided in C# can be categorized as:

C# Variable Type :

  • Integral types :-Sbyte, byte, short, ushort, int, uint, long, ulong and char
  • Floating point types:-  Float and double
  • Decimal types :- Decimal
  • Boolean types :- True or false values, as assigned
  • Nullable types :- Nullable data types

C# also allows defining (declare) other value types of variable like reference types of variables and enum type. reference types  like class.
Variable Definition or declare in C# language:
 C# Variables,How to declare in C#:
 C# Variables

Syntax in C# Variable is:

<data_type> <variable_list>;
Here, data_type must be a valid C# data type including char, float, double,int,  or any user-defined  etc.and variable_list may consist of one or more  names separated by commas.

Some valid C# variable Example are  here:

char c, ch;
int i, j, k;
float f, salary;
double d;

Variable Initialization in C# :

Variable initialize means assigned a value to variable with an equal sign. The general form of initialization is.

variable_name = value;

Variables can be initialized in time of their declaration. The initializer consists of an equal sign.
<data_type> <variable_name> = value;

Some examples  of variable initialization are:

int d = 3, f = 5;
byte z = 22;
double pi = 3.14159;
char x = 'x'; 

Examples  of variable initialization in C# :

 class Program
 static void Main(string[] args)
 short a;
 int b ;
 double c;
 /* actual initialization */
 a = 10;
 b = 20;
 c = a + b;
 Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c);

1 comment:

  1. hey) thanks, it's nice explanation of variable)
    In search of various resources with description and examples of variables I've face this one -, just check how it explains basics of c#! the funniest way I've ever met)))))))))))