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

I have .cs file in my app_code folder i need to create methods in that .cs file through user inter face

Function Name:.....
SourceCode:
.....
......
.......

I have this requirement, after writing the source code for that function it must be stored in .cs file which is already existing
Posted

The big question is if you would like the use this code in run-time or not.

If not, then it's simple - you need to parse your code (text) file (I guess you'll need to build your own parser) and insert the text from the UI according the UI specification, simply by writing the text to the cs file. And there are tons of examples of writing text to a text file.

NOTE: You will have to compile the new code in order to use it, so if you are thinking about run-time compilation, it's a whole different ball game of loading the assembly and using it...

Cheers,
Edo
 
Share this answer
 
Comments
Divyay208 21-Feb-13 2:16am    
I need it in run time only...
Joezer BH 21-Feb-13 2:32am    
Then did you think about compiling the code during run-time?
And then you need to load your assembly, and communicate with it...

It requires a lot more than just editing the CS file!
I suggest you start by reading about run time compilation of C#
e.g. http://www.blackwasp.co.uk/RuntimeCompilation.aspx
This quite simeple just you have to use File operations methods for same namespace
System.IO.File Please let me know if you need code snippet.
 
Share this answer
 
Comments
Divyay208 21-Feb-13 2:15am    
Yah i need code snippet...

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