View Single Post
  #7 (permalink)  
Old March 24th, 2005, 07:57 AM
jacob jacob is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Mehdi and Paulie...

Quote:
quote:you wanted to give a System.Type to your method as a argument(at runtime)and then did a casting to that Type..did you do this?
No, I didn't do that, but I used an interface for the group of possible classes to give as an argument, so in my example all possible types given to the method should implement the interface IMyAttribute.

Quote:
quote:Instead of casting using something like

(Int32) y

In my app, I won't know that y is Int32 at coding time. That info will be loaded from a file or a database. So, if the string variable t is set to "Int32" to hold the type of y, I want to be able to do something like

(Type.GetType("System."+t)) y
That is also what I would like to have accomplished, but I have not been able to do that yet. Still interested in the solution, though. It must be possible due to the quite flexible nature of C#/.NET.

Jacob.