locked
It always go to else block even after condition is true RRS feed

  • Question

  • User1052662409 posted

    Hi All,

     I have a ObjectParameter for my store procedure param6 which is a bool type.

    I need to check if the value is true, it should go to in if block, but here I found strange, after being true it always goes to else block.

    Fro reference please see the pic below.

    Untitled 

    Please suggest.

    Thanks

    Wednesday, May 8, 2019 3:06 AM

Answers

  • User288213138 posted

    Hi  demominside9,
     

    I tried to reproduce your problem and found that changing "true" to "True" would be fine.

     

    The Code:

    static void Main(string[] args)
            {
                bool b = true;
             
                if (Convert.ToString(b)=="True")
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
                Console.ReadKey();
            }

    Best Regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 8, 2019 6:28 AM