Suppose I have the following disposable class and example code to run it:
public class DisposableInt : IDisposable
{
private int? _Value;
public int? My
Why is this?
Variables declared in using
statements are read-only; out
and ref
parameters aren't. So you can do this:
DisposableInt theInt = new DisposableInt(1);
using (theInt)
{
AddOne(ref theInt);
}
... but fundamentally you're not using the fact that it's a ref
parameter anyway...
It's possible that you've misunderstood what ref
really means. It would be a good idea to read my article on parameter passing to make sure you really understand.