What is the difference between ref and out parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can’t?
What is the difference between ref and out parameters in .NET? What are the
Share
They’re pretty much the same – the only difference is that a variable you pass as an
outparameter doesn’t need to be initialized but passing it as arefparameter it has to be set to something.Refparameters are for data that might be modified,outparameters are for data that’s an additional output for the function (egint.TryParse) that are already using the return value for something.