How to dynamically create a C# Class. I have 3 method informations. I have to create a dynamic C# class and it should consist of those 3 methods. Any ideas?..
Asked
Active
Viewed 481 times
1 Answers
3
if saying class
, you need just to have a type
with this 3 methods, you can use DynamicObject.
This is special type of objects in C#
, that permits runtime add/remove of members to an instance of that type.

John Willemse
- 6,608
- 7
- 31
- 45

Tigran
- 61,654
- 8
- 86
- 123
-
Can u please give me some exaples? – senthil kumar May 16 '13 at 07:55
-
@senthilkumar Here's an example of how to use DynamicObject: http://msdn.microsoft.com/en-us/library/ee461504.aspx – Ergwun May 16 '13 at 08:02
-
Can u please explain with some example. Like, my dynamic class name (Type) should be Test and the method details are.. Method 1: public int add(int a, int b) {....} Method 2: public void display(string str){....} Method 3 public string SayHello(string name){....} – senthil kumar May 16 '13 at 08:11
-
@senthilkumar: that was actually a point in my asnwer. If you need some precise type, so *named* type, you should follow the link of the answer that was deleted (don't know why) were you create a *new type*. Here is it: http://stackoverflow.com/questions/3862226/dynamically-create-a-class-in-c-sharp – Tigran May 16 '13 at 08:14