I wanna know is there any way to pass generic type to another Class as an argument.
In other words. I have SomeClass<T> and AnotherClass.
I wanna AnotherClass to have an instance field of Type <T> who would be initialized in constructor.
(I want SomeClass to be list of AnotherClass objects. Another Class would have 3 instance fields reference to previous AnotherClass object reference to next AnotherClass object and a T type field.
Sounds like you're making a generic container. You need something like:
class Container<T>
{
public T Value;
public Container( T rhs )
{
Value = rhs;
}
}
That's basic generics in C#. If you provide more description, I can better answer your question, but based on the info provided, this is what you're looking for.
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