Did You Know?
You can set class fields with ‘out’ method parameters
Whether you like
out parameters or not in C#, they are here to stay. They decorate a number of common patterns in the .NET ecosystem.
TryParsepattern where the return is a
boolthat indicates success and your parse result comes from the
However, very often you want to set your class field with the parse result. At first you would assume that you need to declare a temporary variable to hold the value and then assign the field.
However, this isn’t necessary. Turns out you can just set the field directly.