How to create a List of ValueTuple?
2018-10-17 15:21
561 查看
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;
相关文章推荐
- Python: how to create a list of n lists [[],[],[]]
- R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)
- Example of how to implement a view-based source list (NSOutlineView) using Cocoa Bindings
- How to Fix “HTTP Error 403.14 – Forbidden The Web server is configured to not list the contents of this directory”
- How to create functions that can accept variable number of parameters such as Format
- How to create a SharePoint List using Excel 2003(转贴)
- how to create list box example
- How to create a custom list with custom views based upon a custom list definition
- How to Output a List of Files to a File and Sort Them in Linux
- How-to: resolve " java.lang.OutOfMemoryError: unable to create new native thread" for hbase thrift
- [monitoring] how to create script to monitoring the status of orders and make graphs
- How to bind a GridView to a list of multiple types? NHibernate proxy causing problems with databinding [From stack overflow]
- BLToolKit: how to insert a list of objects?
- How to create Linked list using C/C++
- How to easily create popup menu for DevExpress treelist z
- How to convert a list of tensors into a tensor
- How to Get a List of Class Attributes in Python
- List of maintainers and how to submit kernel changes
- How to create a Windows can run top of Metro UI under windows8c
- How to create a project with existing folder of files in Visual Studio?