Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you mean dynamically create a class, then the two options are:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/3y322t50.aspx" rel="nofollow noreferrer">Reflection.Emit</a> - Difficult, Fast to create the class</li> <li><a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" rel="nofollow noreferrer">CodeDom</a> - Less Difficult, Slower to create the class</li> </ul> <p>If you mean create an instance of an existing class, then start with <a href="http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx" rel="nofollow noreferrer">Activator.CreateInstance</a> to create an instance of the object, and then look at the methods on <a href="http://msdn.microsoft.com/en-us/library/system.type.aspx" rel="nofollow noreferrer">Type</a> such as <a href="http://msdn.microsoft.com/en-us/library/system.type.getproperty.aspx" rel="nofollow noreferrer">GetProperty</a> which will return a <a href="http://msdn.microsoft.com/en-us/library/system.type.getproperty.aspx" rel="nofollow noreferrer">PropertyInfo</a> that you can call <a href="http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.getvalue.aspx" rel="nofollow noreferrer">GetValue</a> and <a href="http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.setvalue.aspx" rel="nofollow noreferrer">SetValue</a> on.</p> <hr> <p>Update: For the scenario you describe, returning dynamic data from a web service, then I'd recommend against this approach as it's hard for you to code, and hard for statically-typed languages to consume. Instead, as suggested in the comments and one of the other answers, some sort of dictionary would likely be a better option.</p> <p>(Note that when I say return some sort of dictionary, I am speaking figuratively rather than literally, i.e. return something which is conceptually the same as a dictionary such as a list of key-value pairs. I wouldn't recommend directly returning one (even if you're using WCF which does support this) because it's typically better to have full control over the XML you return.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload