繁体   English   中英

这个方法返回什么? (C#)

[英]What does this Method return? (C#)

不久前,我从 Java 转到 C# 并且我还在学习,今天我在一些代码中遇到了这个问题。

public async Task<(decimal Price, string NativeCurrency)> GetCurrentStockPrice(string ticker)

我想知道仅基于方法签名该方法究竟返回什么? 它是否返回两个值?

这将返回一个元组(decimal Price, string NativeCurrency)

所以你会打电话

var currentStockPrice = await GetCurrentStockPrice("USD") //or whatever the ticket string needs to be instead of "USD"

currentStockPrice.Item1 is decimal Price
currentStockPrice.Item2 is string NativeCurrency

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM