guess I wanted to gernerate a commandline with flags and so on. Flags are of type bool but the commandline is a string like " /activeFlag". Is there a way to program a setter in C# which takes a bool but the getter returns a string?
like
private string activeFlag {
get { return activeFlag; }
set {
// the value here should be the bool
activeFlag = value ? " /activeFlag" : "";
}
}
There no way to have a property with different data types for its setter and getter.
What you can do is something like this:
private bool IsActiveFlagSet { get { return ActiveFlag == " /activeFlag"; } }
private string ActiveFlag { get; set; }
You need another setter.
private string activeFlag {
get { return _activeFlag; }
}
private bool activeFlagByBool {
set {
// the value here should be the bool
_activeFlag = value ? " /activeFlag" : "";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With