Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# base vs this

// The 'this' keyword represents the current class instance.
// While 'base' access's a method on the parent.

// Example of usage:
public class Parent
{
    public virtual void Foo() {}
}

public class Child : Parent // Derive from 'Parent' class
{
    public override void Foo()
    { base.Foo(); } // call the virtual method on 'Parent'

	// The override is basically not doing anything in this case, since we do
	// exactly the same thig as in the parent method (which in this case is nothing).
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #base
ADD COMMENT
Topic
Name
2+6 =