最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#動態(tài)編譯并執(zhí)行字符串樣例

 更新時間:2020年11月17日 14:48:24   作者:王寶會  
這篇文章主要為大家詳細介紹了C#動態(tài)編譯并執(zhí)行字符串樣例,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

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();
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

屏南县| 石首市| 汉阴县| 太和县| 肥东县| 宁阳县| 渝中区| 商水县| 裕民县| 合江县| 二连浩特市| 杂多县| 夏邑县| 大姚县| 平遥县| 武邑县| 古交市| 阜城县| 嘉祥县| 和平县| 叙永县| 兰考县| 福安市| 通河县| 积石山| 微山县| 长春市| 韩城市| 建水县| 合川市| 肥乡县| 郓城县| 铜川市| 萨嘎县| 博兴县| 靖边县| 宿迁市| 雅江县| 景东| 临邑县| 白银市|