About Generics
.NET has a concept called Generics and PowerShell, as a .NET language, can make use of generic types and methods.Microsoft describe this as follows in an article with the same name as this section:
Generic classes and methods combine reusability, type safety, and efficiency in a way that their non-generic counterparts cannot.
Source: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/genericsThe use of generic classes, or types, is common in modern use of PowerShell.
Generic classes
.NET has the concept of a generic class, some of these are very common such as System.Collections.Generic.List<T>
where "T" is a type that must be declared when the instance is created. For example:
[System.Collections.Generic.List[string]]::new()
Generic types avoid the cost of what is known as Boxing. This is where a value is wrapped in an instance of System.Object
before it is stored.The cost of boxing is unlikely to be noticeable in the vast majority...