代码:
public class Program
{
public static void Main(string[] args)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // 加这句代码后就可解决乱码问题
Console.WriteLine("你好!");
Console.Read();
}
}
project.json配置文件:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"System.Text.Encoding.CodePages": "4.3.0" // 添加包
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}