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

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

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

本文實例為大家分享了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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

凤凰县| 定西市| 寿阳县| 武汉市| 云梦县| 阿勒泰市| 宁夏| 万州区| 诸城市| 闽侯县| 镇雄县| 星子县| 富川| 闸北区| 石河子市| 滁州市| 连云港市| 溧水县| 望谟县| 富顺县| 阜康市| 乐业县| 灌阳县| 汤原县| 平武县| 炉霍县| 仁化县| 桂东县| 昆明市| 贵溪市| 北宁市| 勃利县| 进贤县| 安溪县| 珲春市| 马边| 邹平县| 搜索| 潜江市| 孟津县| 六枝特区|