.net - returning IList<T> vs Array in C#? -
I was just asking someone why he liked to return a strongly written array on an ILID I always Thought that programming against an interface was a flexible and best way to program when faced with a project with a long life. So he hit me strangely when he replied:
We usually prefer floating types with unstable types. Areas are irreversible, not ILIT.
I am not convinced that I understand this statement. Can anyone help clarify this?
Thanks for any help, you can provide people.
I think that he probably think that the property of an array length is irreversible, The array more is fixed in comparison to the ILST or maybe he used the wrong word and who knows the temporary, but this is a strange answer.
I think that with a return to a list there is a little bit that it is ok to modify or it can change during the return of the array, this does not mean as much as it is. For example, if you had an object model at the top of a repository and had a method like a GETCARS () that used to bring the cars back to the list and a junior programmer. Car (add c.) ... would you think he was completely crazy for the thinking of cars? Add (new car) can actually add a car to the repository? Arrays are just underlying and more obvious.
I think the list usage is more suitable in properties like Page Control. Add
I like frequent returning arrays from a list of several reasons.
-
Collections stored in Habit 1.0 / 1.1
-
I like the simplest return to my methods & amp; The most lightweight item they can do if it is mandatory to make a list, then
-
1.1 and if I can at least re-use some of my code or apply a similar object model to older versions of the runtime.
Comments
Post a Comment