c# 动态编译代码 执行脚本代码 关键字还会变色
// debug it step by step (F10, F11)
using System; // for Console.WriteLine
using System.Windows.Forms; // for MessageBox.Show, ...
using System.Diagnostics; // for Debug.WriteLine
using System.Collections.Generic; // for List
// we can call static functions
MessageBox.Show("Hello World!");
// output to DevStudio Output
Console.WriteLine("Hello World!");
// same output over Debug
Debug.WriteLine("Hello World!");
// we can define global var's
var anystr = "Hello World {0} {1}";
int anynuber = 1;
float anyfloat = 3.14f;
// and we can use it
Console.WriteLine(string.Format(anystr, anynuber, anyfloat));
// we can write functions
string test1(int i, string s)
{
return s + " " + i;
}
double test2(double x)
{
double t = Math.Sin(x); // with local vars of course
return t * t;
}
1