user4884237
user4884237

Reputation:

Implement Interface and accessing methods

public partial class shoppingCart : ISecurisable
{
    public void Deactivate() 
    {
        shoppingCartid = null;
        IsActive = false;
        foreach (var shoppingCartDetails in Childs)
        {
            shoppingCartDetails.ParentId = ParentId;
        }
    }
}

How can I access the Deactivate() method after I've implemented ISecurisable on the class.

Upvotes: 2

Views: 53

Answers (2)

You can use this form

ISecurisable shoppingCart = new shoppingCart();
shoppingCart.Deactivate();

public interface ISecurisable
{
    void Deactivate();
}

public partial class shoppingCart : ISecurisable
{
     public void Deactivate()
     {
         shoppingCartid = null;
         IsActive = false;
         foreach (var shoppingCartDetails in Childs)
         {
            shoppingCartDetails.ParentId = ParentId;
         }
     }
}

Upvotes: 0

MakePeaceGreatAgain
MakePeaceGreatAgain

Reputation: 37000

First create an instance of your ShoppingCart-class

ShoppingCart cart = new ShoppingCart();

Now call the method

cart.Deactivate();

Upvotes: 2

Related Questions