本文實例為大家分享了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();
}
}
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持html5模板網。
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!