-1

Ill start with an example or two. Take the following sample class:

class Sample
{
    private object _someObject;

    public Sample(object someobject)
    {
        _someObject = someobject;

        // If I then wanted to pass someobject to a method within the constructor, 
        // is it better to use the field version or the parameter version. Example:

        SomeMethod(someobject);

        // OR

        SomeMethod(_someObject);
    }
}

Additionally, I have just finished the book titled "Efficient C#" by Bill Wagner and would like to know if there are any more books out there with a similar format as this one.

I am interested in knowing why I should write code the way it is written (More efficient IL for example)

Thanks in advance guys :)

4

1 回答 1

3

没有区别,它们都是对同一个对象的引用。

于 2013-07-02T14:48:34.067 回答