Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Equivalent to eval()
Message
From
29/03/2010 12:22:57
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/03/2010 20:02:25
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01457734
Message ID:
01457871
Views:
51
>I have a number of properties which are objects ( business objects )
>
>If I have string which is the same as the name of one of those properties I would like to find the value of a property of the corresponding object.
>
>in VFP
>
>*property is called _Propmaster
>
>varstr = "Propmaster"
>prop = "_"+varstr+".count"
>
>mycount = eval(prop)
>
>
>Looking for a technique that will accomplish the same thing in .NET
>
>vb or C#
>
>TIA

There are many ways to do things in .Net just like VFP:) One way would be to use TypeDescriptor class. ie:
PropertyDescriptor pd = TypeDescriptor.GetProperties( myObj ).Find( myProperty, true );
if (pd != null)
   var value = pd.GetValue( myObj );
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform