何時使用 in vs ref vs out - When to use in vs ref vs out

問題:

Someone asked me the other day when they should use the parameter keyword out instead of ref .前幾天有人問我什麼時候應該使用參數關鍵字out而不是ref While I (I think) understand the difference between the ref and out keywords (that has been asked before ) and the best explanation seems to be that ref == in and out , what are some (hypothetical or code) examples where I should always use out and not ref .雖然我(我認爲)理解refout關鍵字( 之前已經問過)之間的區別,並且最好的解釋似乎是ref == inout ,但我應該始終使用哪些(假設或代碼)示例使用out而不是ref

Since ref is more general, why do you ever want to use out ?既然ref更通用,你爲什麼要使用out Is it just syntactic sugar?它只是語法糖嗎?


解決方案:

參考一: https://stackoom.com/question/6Mbk
參考二: When to use in vs ref vs out
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章