在visual studio中的.cs文件中创建方法 [英] creating methods in .cs file in visual studio

查看:753
本文介绍了在visual studio中的.cs文件中创建方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..



我的app_code文件夹中有.cs文件我需要通过用户界面在.cs文件中创建方法



功能名称:.....

SourceCode:

.....

......

.......



在编写该函数的源代码后,我有这个要求它必须存储在已存在的.cs文件中

解决方案

最大的问题是你是否希望在运行时使用这段代码。 />


如果没有,那么它很简单 - 您需要解析代码(文本)文件(我想你需要构建自己的解析器)并插入根据UI规范从UI中获取文本,只需将文本写入cs文件即可。并且有很多将文本写入文本文件的示例。



注意:您必须编译新代码才能使用它,所以如果你是考虑到运行时编译,它是装载组件并使用它的完全不同的球类游戏...



干杯,

Edo


这个相当simeple只是你必须使用相同命名空间的文件操作方法

System.IO.File如果你需要代码片段,请告诉我。

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

解决方案

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


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.


这篇关于在visual studio中的.cs文件中创建方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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