I am looking at some of my professor's code for him while he is on Holiday and i came across this unreferenced class. Can someone please explain what T represents and possibly how to instantiate a class such as this?
public class RowToObject<T> where T : new()
T
is anything with a public parameterless constructor as constrained by:
where T : new()
To instantiate it, provide a type for T
that has a public parameterless constructor:
var myRowToObject = new RowToObject<AnotherClass>();
As for how it's intended to be used in your code-base, no idea! :-)
RowToObject is a generic class, it takes a type in parameter. This type is identified by T and the constraint (T : new()) enforces that this type must have a default constructor.
More on constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With