C# ref question again?

Posted by TheMachineCharmer on Stack Overflow See other posts from Stack Overflow or by TheMachineCharmer
Published on 2010-04-16T06:47:01Z Indexed on 2010/04/16 6:53 UTC
Read the original article Hit count: 241

Filed under:
|

class Foo { public int A { get; set; } }

class Program
{
    static void Main(string[] args)
    {
        var f = new Foo();
        var ff = f;

        Console.WriteLine(f.GetHashCode());
        Console.WriteLine(ff.GetHashCode());

        FooFoo(ref f);
        BarBar(f);
    }

    private static void BarBar(Foo f)
    {
        Console.WriteLine(f.GetHashCode());
    }

    private static void FooFoo(ref Foo f)
    {
        Console.WriteLine(f.GetHashCode());
    }
}

OUTPUT:

58225482
58225482
58225482
58225482

What is the difference between FooFoo and BarBar?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET