【发布时间】:2017-04-18 03:16:37
【问题描述】:
我正在尝试在 macOS 的 Visual Studio Code 中实现元组 c# 7 新功能。
using System;
using System.Collections.Generic;
namespace newcsharp
{
public class Program
{
public static void Main(string[] args)
{
int[] numbers = { 1, 3, 4, 10, 6, 20, 78, 15, 6 };
var result = Range(numbers);
Console.ReadLine();
}
private static (int Max, int Min) Range(IEnumerable<int> numbers)
{
int min = int.MaxValue;
int max = int.MinValue;
foreach (var n in numbers)
{
min = (n < min) ? n : min;
max = (n > max) ? n : max;
}
return (max, min);
}
}
}
我将 System.ValueTuple 包用于在我的项目中使用元组功能。
我的项目.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"System.ValueTuple": "4.3.0"
},
"frameworks": {
"netcoreapp1.1": {
"imports": "dnxcore50"
}
},
"tooling": {
"defaultNamespace": "newcsharp"
}
}
任何帮助表示赞赏。
【问题讨论】:
-
请在此处粘贴代码,而不是屏幕截图。
-
删除了屏幕截图并添加了代码。
-
msdn.microsoft.com/en-us/magazine/mt595758.aspx Essential .NET - 设计 C# 7
-
核心是否支持 C# 7 功能?我的印象是它目前没有(无论如何)。
-
目前 NET Core 应用程序中似乎不支持
System.ValueTuple命名空间
标签: c# visual-studio-code .net-core c#-7.0