从a中检索项目Tuple
是通过访问该ItemX
属性来完成的.有没有一种方法来命名每个项目,以便使用元组将更具可读性?
码:
寻找这样的东西:
Dim l As New Tuple(Of String, Integer)
l.Name
l.ID
Run Code Online (Sandbox Code Playgroud)
代替:
Dim l As New Tuple(Of String, Integer)
l.Item1
l.Item2
Run Code Online (Sandbox Code Playgroud)
在C#7版本中,我们具有为Tuple Values提供友好名称的功能.注意:只需直接输入此处未编译的代码即可.
例如
(int Latitude, int Longitude, string city) GetPlace()
{
return(20,30,"New York");
}
var geoLocation = GetPlace();
WriteLine($"Latitude :{geoLocation.Latitude}, Longitude:{geoLocation.Longitude}, City:{geoLocation.city}");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3923 次 |
最近记录: |