How to create a List of ValueTuple?
ValueTuple需要通过NuGet安装System.ValueTuple
https://docs.microsoft.com/en-us/dotnet/csharp/tuples?view=netframework-4.7.2
https://docs.microsoft.com/en-us/dotnet/api/system.valuetuple?view=netframework-4.7.2
https://stackoverflow.com/questions/44250462/how-to-create-a-list-of-valuetuple
You are looking for a syntax like this:
List<(int, string)> list = new List<(int, string)>();
list.Add((3, "test"));
list.Add((6, "second"));
You can use like that in your case:
List<(int, string)> Method() =>
new List<(int, string)>
{
(3, "test"),
(6, "second")
};
You can also name the values before returning:
List<(int Foo, string Bar)> Method() =>
...
And you can receive the values while (re)naming them:
List<(int MyInteger, string MyString)> result = Method();
var firstTuple = result.First();
int i = firstTuple.MyInteger;
string s = firstTuple.MyString;
How to create a List of ValueTuple?的更多相关文章
- Tuple和 ValueTuple
这个类型还是学习C#7.0的语法在看到的,这边单独拿来学习下. 学习地址: https://docs.microsoft.com/zh-cn/dotnet/csharp/tuples https:// ...
- C# 7 .NET / CLR / Visual Studio version requirements
C# 7 .NET / CLR / Visual Studio version requirements You do NOT need to target .NET 4.6 and above, ...
- 详解C# Tuple VS ValueTuple(元组类 VS 值元组)
C# 7.0已经出来一段时间了,大家都知道新特性里面有个对元组的优化,并且网上也有大量的介绍,这里利用详尽的例子详解Tuple VS ValueTuple(元组类VS值元组),10分钟让你更了解Val ...
- Tuple元组 、 ValueTuple 值元组详解
Tuple元组 Tuple是C# 4.0时出的新特性,.Net Framework 4.0以上版本可用. 元组是一种数据结构,具有特定数量和元素序列,与数组不同,元祖中的元素可以不同的数据类型.比如设 ...
- C# Tuple VS ValueTuple
C# Tuple VS ValueTuple(元组类 VS 值元组) C# 7.0已经出来一段时间了,大家都知道新特性里面有个对元组的优化:ValueTuple.这里利用详尽的例子详解Tuple VS ...
- Tuple VS ValueTuple
深入理解 c# 元组与值元组(Tuple,ValueTuple) 为什么有此文章 首先要说的是我们公司内部技术框架是用 abp.vnext 框架整合而来的,我们架构师对于 abp 相关的知识都很了然于 ...
- 记一次tomcat线程创建异常调优:unable to create new native thread
测试在进行一次性能测试的时候发现并发300个请求时出现了下面的异常: HTTP Status 500 - Handler processing failed; nested exception is ...
- Could not create SSL connection through proxy serve-svn
RA layer request failedsvn: Unable to connect to a repository at URL xxxxxx 最后:Could not create SSL ...
- android 使用Tabhost 发生could not create tab content because could not find view with id 错误
使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...
随机推荐
- java.util.ResourceBundle 用法小介
java中读取配置文件的信息可以采用properties这个类,但是当遇到国际化问题的时候还是不好解决,因而还是最好使用 ResourceBundle这个类,其实ResourceBundle本质上和P ...
- uva 11995 判别数据类型
Problem I I Can Guess the Data Structure! There is a bag-like data structure, supporting two operati ...
- Nk 1430 Divisors(因子数与质因数)
Time Limit: 5000 ms Memory Limit: 10000 kB Total Submit : 432 (78 users) Accepted Submit : 10 ...
- 济南学习 Day 5 T3 am
[题目描述] 众所不知,rly现在不会玩国际象棋.但是,作为一个OIer,rly当然做过八皇后问题.在这里再啰嗦几句,皇后可以攻击到同行同列同对角线,在 n*n的棋盘中,摆放n个皇后使它们互相不能攻击 ...
- 春哥的nginx systemtap调试脚本简单介绍
http://card.weibo.com/article/h5/s#cid=2304185311ad2d0102v9gd&vid=0&extparam=&from=11100 ...
- PYTHON 源码
http://www.wklken.me/index2.html http://blog.csdn.net/dbzhang800/article/details/6683440
- spring启动时加载字典表数据放入map
import java.util.HashMap; import java.util.List; import org.springframework.beans.factory.annotation ...
- OHIFViewer meteor build 问题
D:\Viewers-master\OHIFViewer>meteor build --directory d:/h2zViewerC:\Users\h2z\AppData\Local\.met ...
- 手机号码归属地查询免费api接口代码
依据手机号码查询用户的卡类型.运营商.归属地.区域等信息. 手机归属地实体类 package org.wx.xhelper.model; /** * 手机归属地 * @author wangxw * ...
- 怎样使用ListView?
怎样使用ListView? watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFC ...