Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Roslyn 中是否有任何函数,通过它我可以将我的字符串解析为 MethodDeclarationSyntax?
我有一个包含方法声明的文件,所以我正在将该文件内容读取到字符串,现在我想从该字符串创建一个方法。有什么建议么?
一种选择是将您的字符串解析为“C# Script”,这是一个允许顶级方法声明的 C# 实验版本。正在做:
var tree = SyntaxTree.ParseText("void Foo() {}", options: new ParseOptions(kind: SourceCodeKind.Script));
为您提供包含CompilationUnitSyntax单个方法声明的有效语法树。
CompilationUnitSyntax
我正在尝试使用 android 将图像上传到 C# Web 服务
Web 服务采用以下参数:
byte[] data, string strFileName
但每次我运行应用程序!它给了我这个错误: