About This eBook by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Accessing Fields

Depending on whether the field is declared as static or as an instance field, it can be accessed in a different manner. For instance fields, you must qualify the lookup by specifying the target instance. To access a field from within the declaring type, you can omit the target instance qualification or use this:

class Person{    private string _name;    private int _age;    public override string ToString()    {        return _name + " is " + this._age;    }}

You’ll learn what the override modifier on a method means in Chapter 14. It’s also essential to realize that the private access modifier doesn’t prevent you from accessing another instance’s private fields as long as that access happens within ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required