0 Members and 2 Guests are viewing this topic.
int foo;public int Foo { get { return foo; } set { foo = value; }}
get { return foo; }private set { foo = value; }
get { return foo; }set { if (value < 100) foo = value; }
get { return foo; foo = 0; }set { foo = value; RickRoll();}
public int Area {get { return width*height; }}
class Properties { private int property_; public int getProperty() { return property_; } private void setProperty(int property) { property_ = property; }}
Code: [Select]get { return foo; foo = 0; }set { foo = value; RickRoll();}This code sets foo to zero after its value is read, and also calls the method RickRoll when foo is set.
3. Capitalize the names of public members, and leave private members as lowercase. This will help you seperate the two.
Quote from: Compynerd255 on March 16, 2011, 10:41:12 amCode: [Select]get { return foo; foo = 0; }set { foo = value; RickRoll();}This code sets foo to zero after its value is read, and also calls the method RickRoll when foo is set.I'm not sure if foo = 0; gets executed after a return...
set { foo = value; if (foo > 9000) Console.Writeline("It's over 9000!");}