Real-world examples where C# 'out' parameters are useful?

后端 未结 8 857
逝去的感伤
逝去的感伤 2020-12-29 06:46

I\'m reading up on core C# programming constructs and having a hard time wrapping my head around the out parameter modifier. I know what it does by reading but

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 07:02

    bool Int32.TryParse(String, out Int);
    

    or something similar like Dictionary.TryGetValue.

    But I would consider this one to be a not too good practice to employ it, of course, using those provided by API like the Int32 one to avoid Try-Catch is exceptions.

提交回复
热议问题