J
Jure Bogataj
Hi all!
I was wondering if it is possible to create methods within generic classes,
based on what type class operates on:
e.g.
public class ListEx<T> : List<T>
{
public void MyMethod<int>(int param1, int param2)
{
}
public void MyMethod<string>(string param1, string param2)
{
}
}
So, MyMethod<int> would only be available if instance of class is declared:
ListEx<int>
and MyMethod<string> would only be available if class declared like:
ListEx<string>
Is this at all possible with generics?
Thanks in advance!
Best regards, Jure
I was wondering if it is possible to create methods within generic classes,
based on what type class operates on:
e.g.
public class ListEx<T> : List<T>
{
public void MyMethod<int>(int param1, int param2)
{
}
public void MyMethod<string>(string param1, string param2)
{
}
}
So, MyMethod<int> would only be available if instance of class is declared:
ListEx<int>
and MyMethod<string> would only be available if class declared like:
ListEx<string>
Is this at all possible with generics?
Thanks in advance!
Best regards, Jure