0

I think it's more difficult to ask than answering the question.
I wanna ask my question with an example:
You know that we can bind an object to a DataSource, and that object could be of any type. So suppose I've bound an object of type "MyClass" to DataSource of a DataSet.
Now I send this dataset as a parameter to another class in another DLL, and in this DLL file I want to create a List<> of type of "MyClass".
As I have not access to "MyClass" type i can use this code to get the type of DataSource:

_dataSet.DataSource.GetType()

but I can't use the code like the following to create a List of type of "MyClass":
List<_dataSet.DataSource.GetType()> _list;

What should I do in this situation?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Diamonddrake
0

You can get the type of an object by passing that object to they typeof method.

Type t = typeof(MyClass);

but if the type is not available to the namespace you are in, then it won't work. you need to expose that type to your other dll, and if you can't, then you need to define that type again so that it is available.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.