+ 13

What is a var? Please Explian in an easy way :)

12th Aug 2017, 7:50 AM
Abdulla Abdulwahed
Abdulla Abdulwahed - avatar
24 odpowiedzi
+ 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)
12th Aug 2017, 7:56 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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
14th Aug 2017, 7:22 PM
Fabian Nieves
Fabian Nieves - avatar
+ 15
int a = 1; a - is the variable)
14th Aug 2017, 4:30 PM
Shatmanliev T
Shatmanliev T - avatar
+ 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.
13th Aug 2017, 3:44 PM
Andy
Andy - avatar
+ 5
A var is a box with stuff. Literally. A box in a computer system.
12th Aug 2017, 8:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
var = variable. int = integer. hope I helped u
24th Aug 2017, 3:05 PM
AL.The.Flame!
AL.The.Flame! - avatar
+ 4
V A R I A B L E Something that can change throughout the code.
14th Aug 2017, 1:34 PM
Iwan
Iwan - avatar
+ 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.
15th Aug 2017, 1:28 AM
Kristine Avetisyan
Kristine Avetisyan - avatar
+ 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***
15th Aug 2017, 8:44 AM
keerthana MZ
keerthana MZ - avatar
+ 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 ..
14th Aug 2017, 10:34 AM
SyrianVikings
SyrianVikings - avatar
+ 2
Can store any value..nd doesn't have a fixed one
15th Aug 2017, 10:18 AM
Abhishek Arora
Abhishek Arora - avatar
+ 2
var is any name given by the programmer, which can take any value from the user, to perform a specific task.
15th Aug 2017, 10:50 AM
Hammed Zisa
Hammed Zisa - avatar
+ 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
24th Apr 2018, 5:07 PM
Mante
Mante - avatar
+ 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.
12th Aug 2017, 8:02 AM
sneeze
sneeze - avatar
+ 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 😀
12th Aug 2017, 10:04 AM
D_Stark
D_Stark - avatar
+ 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
12th Aug 2017, 4:31 PM
Farhan Sindy
Farhan Sindy - avatar
+ 1
Oh thanks guys now i understand that var=variable, thanks for even going for more info helped me out :)
12th Aug 2017, 8:03 PM
Abdulla Abdulwahed
Abdulla Abdulwahed - avatar
+ 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
15th Aug 2017, 11:36 AM
Gabriel Sobral
Gabriel Sobral - avatar
+ 1
thanks for the help
26th Aug 2017, 9:16 AM
Abdulla Abdulwahed
Abdulla Abdulwahed - avatar
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
14th Aug 2017, 7:44 PM
Sai Krish
Sai Krish - avatar