var keyword
In C# method scope, a variable can be declared as two types.- Implicit
- Explicit
Explicit means you know the data type like integer, string etc and Implicit means you don’t know the data type.
Example
// Explicit data typeInt i = 5;
string str= “Anjali”;
// Implicit data type
var i=5;
var str=”anjali”;
Note: Var is a statically data type means the data type determine at compile time, not at runtime. Var is a strongly typed means data type can not be changed once it has been declared.
Var i =100; // Correct
I = “Welcome”; // Incorrect
Definition: Var keyword is an implicit way to define the data type. Compiler determines data type when application gets compiled.
No comments:
Post a Comment