Answer the question
In order to leave comments, you need to log in
Is it better to auto or specify the exact type of a variable?
Good afternoon.
nevertheless, I got to the resolver and a small question arose, since he advises throughout the code to change the exact type indicated by me to auto.
what is he doing this for?
Answer the question
In order to leave comments, you need to log in
It all depends on the context of the application.
one)
var list = new ObservableCollection<SomeReallyLongTypeName>();
ComplexType businessObject = DoSomeWork().OtherWork(a,b).GetResult(someArgs);
it's a matter of code conventions.
I will give an example from c # (there is var instead of auto),
for example, if we have a simple type or a local variable is created where something of an unknown type is put
int i = 5;
// или
double localF = _globalF;
var c = new MySuperLongClassName();
// или
var lm = new List<Model>();
The brevity of the record. A classic use case is the use of iterators.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question