簡體   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