+ 13
What is a var? Please Explian in an easy way :)
24 Respuestas
+ 19
var·i·a·ble
/ˈverēəb(ə)l/
noun ~` an element, feature, or factor that is liable to vary or change. In programming, variables are used to store values which can be used for later purposes (e.g. calculation, modification).
(var keyword tho, https://stackoverflow.com/questions/4307467/what-does-var-mean-in-c)
+ 17
That's for declaring a variable(container used to save data) with no data type specifications such as (int, float, string, ...).
for example if you what to declared a integer variable yo could write this:
int x = 10; //x value have to be a integer or it will output error
using the var looks like this:
var x = 10; //in this case x value can be any data type and the program will autistically knows
+ 15
int a = 1;
a - is the variable)
+ 6
var can also be considered as a placeholder for a variable's data type in C#.
When a new variable is declared but the user doesn't want to specify the data type just yet, var keyword can be used instead.
e.g
int AgeNum = 42;
string Name = "learn";
var Age = AgeNum;
var Name2 = Name;
Age takes the int data type from AgeNum while Name2 is a string.
+ 5
A var is a box with stuff. Literally. A box in a computer system.
+ 5
var = variable.
int = integer.
hope I helped u
+ 4
V
A
R
I
A
B
L
E
Something that can change throughout the code.
+ 3
A symbol or name that stands for a value. For example, in the expression x+y, x and y are variables. Variables can represent numeric values, characters, character strings, or memory addresses.
+ 3
var=variable
*the name assigned to a data field that can assume any of a given set of values is defined as variable (or)
*variables are allocated memory to store data
eg: int a;
float f1,f2.;
char name[20],choice;
***variables must be declared before they are used***
+ 2
a variable which is a place in memory to store data ..var is used when we dont want or dont know the type of the returned variable ..while its more flexible for programmers ..its not prefered for allocating memory ..
+ 2
Can store any value..nd doesn't have a fixed one
+ 2
var is any name given by the programmer, which can take any value from the user, to perform a specific task.
+ 2
In C#, it is a keyword you can use to declare a variable, but only when the compiler can deduct it's type and the variable is local.
For example:
var x = 10;
var obj = new MyObject();
// In this two cases, the compiler can
// deduct the type of the variable you
// are declaring
// The var keyword is often used in
// foreach loops to declare the interval
// variable, because lists, arrays exc...
// are all strongly typed
var list = new List<int> { 1, 2, 3 };
foreach (var num in list)
Console.WriteLine(num);
// As you can see, we can omit
// List<int> list = ... in the list
// declaration, as the compiler is able to
// deduct the type.
// We can omit the int in foreach (int
// num in list) too, as the compiler can,
// again, deduct that the list contains
// integer values.
// Some cases when you can't use var
// are in method parameters, class
// properties, fields and
// basically all the cases where you
// cannot deduct the type of a declared
// variable
class MyClass
{
var field1; //Can't use var
var field2 = 1; // Can't use var
var field3 =
new MyClass(); // Can't use var
var Prop1 { get; set; } //Can't use var
var Prop2
{ get; set; } = 10; // Can use var
var Method1 () {} // Can't use var
void Method2 (var param)
{ } // Can't use var
}
In other languages, var keyword may be used differently (Ex. JavaScript)
I hope this was explanatory enough
+ 1
Var is a box around a variable. In this way the variables can be passed more easily through methods. Notice that the type is set on initialisation. Notice also that is not the same as the historic undefined var.
+ 1
var is a variable, sololearn uses var for short so the learner knows where it goes. You dont need to use var you can use any word. try it 😀
+ 1
var = variable, use a variable to store a value,a var will took a place in memory.
ex (on python code) :
n = "this is sting" <- n is a variable , "this is string" is n value.
id(n) -> code to see the address of n in your memory
+ 1
Oh thanks guys now i understand that var=variable,
thanks for even going for more info helped me out :)
+ 1
a space where you can save things for use later, in your code, and give a name for this space, to call and use
+ 1
thanks for the help
0
var means in general programming used for variables...that can vary at any time. It can be understood easily with const referred for constant that does not vary