Boolean int conversion issue

后端 未结 2 1465
庸人自扰
庸人自扰 2020-12-05 22:52

I am working on a trading API (activex from interactive brokers)which has a method called:

void reqMktDataEx(int tickerId, IContract contract, string general         


        
2条回答
  •  时光取名叫无心
    2020-12-05 23:30

    One more way is to have extension method:

    public static class BooleanExtensions
    {
        public static int ToInt(this bool value)
        {
            return value ? 1 : 0;
        }
    }
    

    then it can be used:

    bool result = false;
    result.ToInt();
    

提交回复
热议问题