I know it has been asked several times but I'm having very hard time understanding the <T> concept.
I'm working on a custom GridView and I want to set the Cell.Value property upon CellUpdate event. the problem is that in most cases I will have to take a string from the cell's control input while I have no idea how to 'dynamically' convert (in elegant way) this String to the original object which in this case is represented in _Value as object.
Hope any of this make some sense, thank you.
Generic (<T>) and Dynamic are two opposite concepts. Generics should be known at compile-time and dynamic are resolved at runtime. So if you know the type (<T>) dynamically only at runtime you cannot invoke a generic method unless you use reflection.
Depending on your specific requirements and code you are dealing with there might be different solutions.
Generics and reflections are very hard together and are not recommended to use. If you get to a point where you want to use both together, it is usually a bad design to begin with. Even if it is not a bad design, consider alternatives which would not require you to take this course of action.
I had some experience with generics and reflection and I don't recommend it one bit.
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