Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person
- {
- private int age = 0;
- private int defaultAge = 25;
- public Person()
- {
- this.age = CalculateAge(this.defaultAge); // Possible
- CalculateAge(); // Impossible
- }
- public static int CalculateAge(int age)
- {
- return age;
- }
- public static void CalculateAge()
- {
- // Cannot reference instance fields directly
- age = defaultAge;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement