您的位置:首页 > 编程语言 > C#

C# 6.0 编译器

2015-07-23 10:56 441 查看
C# 6.0编译器:可以将csc.exe所在位置 C:\Program Files (x86)\MSBuild\14.0\Bin 添加到Path环境变量。

C:\>csc
Microsoft (R) Visual C# Compiler version 1.0.0.50618
Copyright (C) Microsoft Corporation. All rights reserved.

warning CS2008: No source files specified.
error CS1562: Outputs without source must have the /out option specified


C# 5.0编译器:仍然在原来的位置 C:\Windows\Microsoft.NET\Framework\v4.0.30319 或者 C:\Windows\Microsoft.NET\Framework64\v4.0.30319

例子:用C# 6.0编译器创建一个GUID生成器

设置Path环境变量

按Win+Break键(或者Win+X,Y)打开系统属性窗口,点左侧的“高级系统设置”,在出现的对话框中点“环境变量”按钮,然后点“新建”,输入用户变量Path和csc.exe所在路径。如果已存在“Path”,点编辑,输入csc.exe所在路径,多个路径用英文分号(;)分隔。



源代码 test.cs

using System;

class Program {
static void Main() {
var guid = Guid.NewGuid();
Console.WriteLine($"{guid:N}\r\n{guid:D}\r\n{guid:B}\r\n{guid:P}");
Console.ReadKey(true);
}
}


编译成nguid.exe

C:\>csc test.cs /out:nguid.exe


运行nguid

C:\>nguid
b2feb26a275540abbba9df43d6161ad6
b2feb26a-2755-40ab-bba9-df43d6161ad6
{b2feb26a-2755-40ab-bba9-df43d6161ad6}
(b2feb26a-2755-40ab-bba9-df43d6161ad6)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: