本文实例为大家分享了Android九宫格图片展示的具体代码,供大家参考,具体内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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(); } } |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。