国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#動態編譯并執行字符串樣例

2020-01-24 00:35:22
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內容如下

using System;using Microsoft.CSharp;using System.CodeDom.Compiler; class Program{  public static void Main()  {    // The C# code to execute    string code = "using System; " +           "using System.IO; " +           "public class MyClass{ " +           "  public static void PrintConsole(string message){ " +           "    Console.WriteLine(message); " +           "  } " +           "} ";     // Compiler and CompilerParameters    CSharpCodeProvider codeProvider = new CSharpCodeProvider();    CompilerParameters compParameters = new CompilerParameters();     // Compile the code    CompilerResults res = codeProvider.CompileAssemblyFromSource(compParameters, code);     // Create a new instance of the class 'MyClass'    // 有命名空間的,需要命名空間.類名    object myClass = res.CompiledAssembly.CreateInstance("MyClass");     // Call the method 'PrintConsole' with the parameter 'Hello World'    // "Hello World" will be written in console    myClass.GetType().GetMethod("PrintConsole").Invoke(myClass, new object[] {"Hello World" });     Console.Read();  }}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大庆市| 凭祥市| 苍溪县| 沅江市| 县级市| 怀柔区| 凤山县| 普洱| 呼和浩特市| 彭州市| 科技| 嘉禾县| 大城县| 龙山县| 双城市| 三原县| 连云港市| 奉节县| 青岛市| 蒙阴县| 阿拉善右旗| 盱眙县| 河间市| 旬邑县| 报价| 思茅市| 霸州市| 哈尔滨市| 堆龙德庆县| 庆元县| 岳阳市| 贡觉县| 综艺| 湖北省| 亳州市| 唐山市| 原阳县| 开封市| 威远县| 治县。| 阜阳市|