About var data type. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

About var data type.

if var itself identifies the value and automatically declares the variable so why we need to use other data types as var does the work?

12th Aug 2017, 4:57 AM
Ankita
Ankita - avatar
2 Answers
+ 1
Var is a Keyword and is used to declare the variables such ass array string etc. Do not use var to declare the data type for the property (properties) as well as the return type of the method (method) in the class.
12th Aug 2017, 6:13 AM
KANHAYA TYAGI
KANHAYA TYAGI - 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. Really you need strong data typing to prevent you from strange u expected errors.
12th Aug 2017, 8:06 AM
sneeze
sneeze - avatar