.Net Core 中的 Console.Write [英] Console.Write in .Net Core

查看:36
本文介绍了.Net Core 中的 Console.Write的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习 .Net Core.我想编写一个简单的Hello World"控制台应用程序.

I start to learn .Net Core. I want to write a simple 'Hello World' console application.

不幸的是,System.Console 最初不可用.这是我的代码:

Unfortunately the System.Console is not available initially. This is my code:

using System;

class Program
{
    public static void Main()
    {
        Console.WriteLine("Hello from Mac");        
    }
}

我应该安装什么包?

仅供参考,我在 Mac 上使用 VSCode 和 .net core rc1 update 2.

FYI, I'm using Mac with VSCode and .net core rc1 update 2.

推荐答案

确保在你的 project.json system.console 下被引用frameworks:dnxcore50:dependencies

Make sure in your project.json system.console is referenced under frameworks:dnxcore50:dependencies

示例 project.json:

Example project.json:

{
  "version": "1.0.0-*",
  "description": "ConsoleApp1 Console Application",
  "authors": [ "danny" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
       "emitEntryPoint": true
  },

  "dependencies": {
  },

  "commands": {
    "ConsoleApp1": "ConsoleApp1"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}

这篇关于.Net Core 中的 Console.Write的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆