Prev: Passing nullable string
Next: Global.asax Session_End
From: Arne Vajhøj on 31 Dec 2008 15:19 G�ran Andersson wrote: > sony.m.2007(a)googlemail.com wrote: >> is there anyway to create dynamic variables at the runtime based on a >> string input from another function >> >> string datatypestring="int"; >> using this datatypestring i need to create a integer variable at run >> time.is there any methods available in reflection to create dynamic >> variables(like int, double etc) > My natural reaction every time this kind of question comes up is: > > - Why do you think that you need to create variables dynamically? > > So far I have never seen a good reason... For fields then a Dictionary<> usually works fine. The only reason I know for doing similar stuff is to dynamicly generate a class at runtime with specific properties, because objects are to be given to something that expects properties not a Dictionary<>. Arne |