#Base and This

1 messages · Page 1 of 1 (latest)

trim quarry
elfin sequoia
#

this is the current object the code is executing on, the context the code runs on

#

base is accessor for the superclass

trim quarry
#

and in which case do you use it?

elfin sequoia
#

base most often for calling implementation of virtual/abstract methods in the base class

#

this when you need to differentiate the local variable, from member variable, or any other case when you need to access current object, or pass it somewhere

#
class Foo{
  public void AcceptBar(Bar bar)  {}
}

class Bar{
  void DoStuff()
  {
  var f = new Foo();
  f.AcceptBar(this);
  }
 }