LogFAQs > #909988969

LurkerFAQs, Active DB, DB1, DB2, DB3, Database 4 ( 07.23.2018-12.31.2018 ), DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicCool function I wrote
Magus 10
10/05/18 2:35:08 AM
#21:


Sahuagin posted...
one use for ref would be maybe if you had a counter that you wanted to pass between methods. then you can share the counter between a bunch of methods and increment it in any one of them. but then you can just put it in an object, too, which is better, so it's not super useful.


Yeah, I'm not sure I'd really want to pass around state like that specifically.

I suppose the Interlocked methods are one example where it's pretty necessary, but I don't think most people are going to need to be implementing that particular set of methods.

Sahuagin posted...
the standard example is something like:

if (!int.TryParse(someText, out var intValue))
...return;

// do something with intValue


Yeah, multiple returns is the scenario I was thinking about with tuples being another option, although I suppose in the case where you're checking an error return value then out params are probably a little easier to use.
---
Internet = Tube0 + Tube1X + Tube2X^2/2! + Tube3X^3/3! + Tube4X^4/4! + ...
... Copied to Clipboard!
Topic List
Page List: 1