KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Having the following generic class that would contain either string, int, float, long as the type: public class MyData<T> { private T _data; public MyData (T value) { _data = value; } public T Data { get { return _data; } } } I am trying to get a list of MyData<T> where each item would be of different T . I want to be able to access an item from the list and get its value as in the following code: MyData<> myData = _myList[0]; // Could be <string>, <int>, ... SomeMethod (myData.Data); where SomeMethod() is declared as follows: public void SomeMethod (string value); public void SomeMethod (int value); public void SomeMethod (float value); UPDATE: SomeMethod() is from another tier class I do not have control of and SomeMethod(object) does not exist. However, I can't seem to find a way to make the compiler happy. Any suggestions? Thank you.
Tags (comma-separated)
Save Edits
Cancel