Click here to Skip to main content
15,911,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to store coding in string.i wrote one function in c#.i want store that function coding in string variable.how is possible that?
Posted
Updated 29-Nov-13 1:18am
v2
Comments
OriginalGriff 29-Nov-13 6:52am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
CPallini 29-Nov-13 6:52am    
?!
agent_kruger 29-Nov-13 7:20am    
do you want to get your code programtically in a string?
Karthik_Mahalingam 29-Nov-13 7:21am    
Please add more info to your question

Hi

If your meaning of question is "You write function from your code for example function.cs and know you want read this file(function.cs) and store in string variable Ok you can do it however I don`t know why you want to do ?

1- you should used System.Reflection and System.IO
1-1- Read your file function.cs with System.IO.StreamReader
C#
System.IO.StreamReader sr = new System.IO.StreamReader("File Path");
string function = sr.ReadLine();


However pay attention to maybe you need to the pars function and remove namespace and other not necessary strings.

2- After that you can use System.Reflection to create instance of your function.cs and for know how do that you can search from google ;-)

Best Regards.
 
Share this answer
 
Hi,
You could prefer StringBuilder[^] instead of string, which is more organized and easy to append and access.
I hope this helps you a bit.

Regards,
RK
 
Share this answer
 

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