Why is this Microsoft UIP Application Block code valid?

  • Thread starter Thread starter BillyM
  • Start date Start date
B

BillyM

The sample code that comes with a StoreController class with the following
method definition:

public void ResumeShopping()
{
State.NavigateValue = "resume";
Navigate();
}

As you can see, the above is not a static method. However, it is consumed in
the Cart class as follows:

private void browseCatalogButton_Click(object sender, System.EventArgs e)
{
StoreController.ResumeShopping();
}

QUESTION: Why is this valid if an instance has not been declared?
 
BillyM said:
The sample code that comes with a StoreController class with the following
method definition:

public void ResumeShopping()
{
State.NavigateValue = "resume";
Navigate();
}

As you can see, the above is not a static method. However, it is consumed in
the Cart class as follows:

private void browseCatalogButton_Click(object sender, System.EventArgs e)
{
StoreController.ResumeShopping();
}

QUESTION: Why is this valid if an instance has not been declared?

The Cart class defines a private property called StoreController:

private StoreController StoreController
{
get{ return (StoreController)this.Controller; }
}

It's confusing that the private property has the same name as its type.
 
Back
Top