日期:2014-05-17  浏览次数:21060 次

使用NotePad++ 运行轻量级的C#代码

有时候想实验个C#代码中的小特性,不得不打开VisualStudio,但这实在是太重量级了,如果电脑性能一般的话,光打开VS就得等半天,这里我们可以使用notepad++来运行

在notepad++中新建文件hello.cs,F5运行,配置命令行

cmd /K C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:$(FULL_CURRENT_PATH).exe $(FULL_CURRENT_PATH) && $(FULL_CURRENT_PATH).exe

文件内容如下:
using System;

public class Program{
	static void Main(){
		Console.WriteLine("hello c#");
	}
}

输出

Microsoft(R) Visual C# 2010 编译器 4.0.30319.1 版
版权所有(C) Microsoft Corporation。保留所有权利。

hello c#