如何使用C#在变量字符串中存储编码? [英] how to store coding in variable string using C#?

查看:132
本文介绍了如何使用C#在变量字符串中存储编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在string.i中编写一个函数在c#中编写了一个函数.i想要存储函数编码在字符串variable.how中可能吗?

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?

推荐答案

你好



如果您的问题的意思是您从代码中编写函数,例如function.cs,并且知道您想要读取此文件(function.cs)并存储在字符串中变量好的你可以做但我不知道你为什么要这样做?



1-你应该用 System.Reflection System.IO

1-1-用 System.IO读取你的文件function.cs .StreamReader

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
System.IO.StreamReader sr = new System.IO.StreamReader("File Path");
string function = sr.ReadLine();





但是要注意你可能需要使用pars函数并删除namespa ce和其他不必要的字符串。



2-之后你可以使用 System.Reflection 来创建实例你的function.cs和你知道如何从谷歌搜索;-)



最好的问候。



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.




您可能更喜欢 StringBuilder [ ^ ]而不是字符串,它更有条理,更容易追加和访问。

我希望这对你有所帮助。



问候,

RK
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


这篇关于如何使用C#在变量字符串中存储编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆