Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I need to compile only c# Method but i don't know how can i do that, i'm trying to lots of example but it's not work form me. can you help for same.

Eg. I have c# method as a string i need to pass string into another method as param/same class its execute and show the result on console.

What I have tried:

Nothing.
Posted
Updated 10-Jul-18 21:18pm
v3
Comments
Ziee-M 12-Feb-18 8:23am    
To show your message in console you can use : Console.Write();
So to post your method, Console.Write(MyMethod("MyString"));
You can also use Debug instead of Console class to show messages in your console

1 solution

Have you looked at this CodeProject article?

Compiling C# Code at Runtime[^]
 
Share this answer
 
Comments
nilvish07 12-Feb-18 8:27am    
Right but i need to only compile method, i don't have class structure.
Dave Kreskowiak 12-Feb-18 8:35am    
So what's preventing you from supplying a generic "class" shell around the method code entered?
phil.o 12-Feb-18 12:40pm    
In C# there cannot be any method outside a class.
#realJSOP 12-Feb-18 13:32pm    
So create a class to which you can add a method. Either that, or create the whole class dynamically (with the desired method).
nilvish07 13-Feb-18 2:53am    
i'm resolved on same way,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900