josef_skywalker
josef_skywalker

Reputation: 1107

Create own class with more than one property

i have the following class:

namespace Mentionfunctions
{
    class MFunctions
    {
        public bool availability(string ean)
        {
             //do
             return true;
        }
    }      
}

I call this one with

MFunctions mf = new MFunctions();
mf.availability(EAN);

I want to add a property to call the function with a different "mode"

I want to do something like:

mf.availability.global(EAN);
mf.availability.onlysupplier(EAN);

I googled this for ours but i'm not sure how do to that or i'm using the wrong words for searching.

Upvotes: 0

Views: 78

Answers (2)

DrKoch
DrKoch

Reputation: 9772

Don't use a property to change the behaviour of a function. Use an additional argument to the function instead:

bool availability(string ean, string mode);

Then make mode an Enumeration

Upvotes: 1

Selman Genç
Selman Genç

Reputation: 101681

You can use enums for that:

enum Mode
{
   global,
   onlysupplier
}

public bool availability(string ean, Mode m) { }

Then you can call your method like this:

mf.availability(EAN, Mode.global);

Upvotes: 5

Related Questions