Windows下编译C#程序(无MSVS)

  • 使用 .NET Framework的 csc 命令,在目录
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
  • 步骤如下:
  1. 编写测试程序 CallCmd.cs 如下
using System;
class Test
{
    public static void Main(String[] args)
    {
      Console.WriteLine("Hello, Mr.Tree!");
    }
}
  1. 在该目录下执行命令
D:\Test>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe CallCmd.cs
Microsoft (R) Visual C# Compiler version 4.8.3752.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
  1. 完成后在同目录下生成 CallCmd.exe ,执行命令测试。
D:\Test>CallCmd.exe
Hello, Mr.Tree!

你可能感兴趣的:(Memos,Windows应用,c#,编译,无vs)