Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - Create object from a string?
Message
From
07/04/2008 17:28:16
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01308851
Message ID:
01308857
Views:
6
If you are working with something as simple as just a name, even with a few more properties such as phone, address, etc., you can create an object type called "struct". This looks like a little like a class, but is technically very different.

But you can create a struct with properties of fname, lname, etc., and pass the struct around like any other type of variable.

>I'm very new to C# so please forgive me if this is a really simple question.
>
>Given the following code:
>
>string myString = "{fname='Joe', lname='Smith'}";
>
>
>Is there any way to use myString to actually instantiate an object with two properties (fname and lname)?
>
>I know I can do this:
>
>var myObject = new {fname='Joe', lname='Smith'};
>
>
>So I guess what I'm asking is, is there a way to dynamically use myString something like this: (I know this doesn't work but its here to give an idea of what I'm wanting to do)
>
>var myObject = new (myString);
>
>
>Thanks for your help!
>
>Rodd

(On an infant's shirt): Already smarter than Bush
Previous
Reply
Map
View

Click here to load this message in the networking platform