Re: String2DataType function
Casting is a compile time process, not runtime. If you need to dynamically create an object of an unknown type at runtime you will need to look into reflection and you will also need an interface so that you can use the object in your code.
Re: String2DataType function
I have no idea what you are trying to achieve.
Re: String2DataType function
I think what you need is to Use Activator.CreateInstance to create an object from a string:
Check: http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
Re: String2DataType function
So you have the name of the type and you want to cast and object to that type.
Somebody have had a similar problem over at stack overflow check it out, it might help you:
http://stackoverflow.com/questions/7...representation
Re: String2DataType function
Thank you all for your replies. I changed the implementation so I won't require to do it, it was a poor design that has thrown me to the place I needed to do that.
I was sending serialized objects through the network. I wanted to add a header string in each message indicating the object being serialized so the other side can cast it in the right way.
I'm not sending serialized objects anymore, messages are embedded within a xml structure.
Thank you all, again. I really appreciate it.
Best regards.