6
There is a difference between these two ways to start a variable?
List<classeterapeutica> itens = new List<classeterapeutica>();
modelOff.classeterapeuticas.ToList();
or
List<classeterapeutica> itens = modelOff.classeterapeuticas.ToList();
6
There is a difference between these two ways to start a variable?
List<classeterapeutica> itens = new List<classeterapeutica>();
modelOff.classeterapeuticas.ToList();
or
List<classeterapeutica> itens = modelOff.classeterapeuticas.ToList();
5
It is not a matter of being correct, but initializing a variable with a value to exchange that value in the next line makes no sense, so the second code is preferable. Only assign a value to a variable if this value will be used somewhere. If it is discarded unused it is something bad.
Browser other questions tagged c# variables variable-declaration
You are not signed in. Login or sign up in order to post.
then what would be the logic of using
new class();
? because I’ve seen many codes like this.– Italo Rodrigo
In a case similar to this one you don’t have. A lot of code out there is misspelled. You always have to see the context. There is no magic formula for programming correctly.
– Maniero