That specifically is a namespace of . NET. See in another question. Just like in PHP, if something is inside a namespace needs to be "imported" to gain access to its members (unless you use the full name).
Obviously the library containing these types needs to be referenced in the project as well, but that’s another problem outside the language itself.
The method Select()
is a generic algorithm for manipulating any type of IEnumerable
(has question about this interface). Has various algorithms thus. This is part of the language of consultations with enumerable collections of data, the so-called LINQ.
To documentation shows interfaces implemented by type Array
(beware because the class linked here is just a utilitarian for the type that is native in the language and does not represent the type itself, as it usually happens in other types).
The methods that are in this namespace specific are extension methods (specifically in static class Enumerable
(see her source) and no. NET Core became more organized), then they appear to be of the type itself, but are external, so they need to be explicitly referenced - through the namespace - when you want to use them.
Could be normal functions (normal static methods), but would lose the syntax uniformity and the ease to find out what is available to the type when using an auto-completion mechanism of an IDE.
Use of the extension method:
objeto.Metodo()
Use of normal static method:
Classe.Metodo(objeto)
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
I won’t go into details about extension methods because you already have a specific question goes up and we don’t need to repeat here.
It has a not very recommended technique for not having to do this in its extension methods: it creates the class that will contain these methods within the namespace which will usually have the types they extend. For example, if you put your methods in the namespace System
, then it is likely that they will always be available. But there is a risk of having name collisions for free.
See more about the LINQ.
Example of use.
See if I need to answer anything else, or I need to get better to clarify more.
– Maniero