1
I have some questions about the method of constructing a class that I am seeing as an example, if anyone can explain thank you.
private static IList<Categoria> categorias = new List<Categoria>()
{
new Categoria() {
CategoriaId = 1,
Nome = "Notebooks"},
new Categoria() {
CategoriaId = 2,
Nome = "Monitores"},
new Categoria() {
CategoriaId = 3,
Nome = "Impressoras"},
new Categoria() {
CategoriaId = 4,
Nome = "Mouses"},
new Categoria() {
CategoriaId = 5,
Nome = "Desktops"},
};
1st doubt - what is the use of the word static
in that case?
2nd doubt - why was declared categories as IList
of Categoria
and received a List
, that is, what is the difference between List
for IList
?
If you add more snippets, you can give more context and get a better answer. But it seems that these two questions already have answers here. http://answall.com/q/86484/101 and http://answall.com/q/73633/101 (is Java, but works equally), http://answall.com/q/76316/101 and http://pt.stackoverflowcom/q/136913/101. Complement: http://pt.overfstacklow.com/q/139045/101. To
static
: http://answall.com/q/99603/101. http://answall.com/q/96710/101 (java, but equal). Example of use: http://answall.com/q/134576/101– Maniero
I wanted to know why in this example was used Ilist to declare categories, could not have used only the direct List ? in the case: private Static List<Category> categories = new List<Category>
– Desalex
http://stackoverflow.com/questions/400135/listt-or-ilistt
– sir_ask
No one thought I should close, I gave an answer that might be a little more useful.
– Maniero