Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Equivalent to eval()
Message
De
29/03/2010 12:22:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/03/2010 20:02:25
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01457734
Message ID:
01457871
Vues:
53
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform