Int32.TryParse() returns zero on failure - success or failure?

后端 未结 5 1627
萌比男神i
萌比男神i 2021-01-01 09:06

I read this from msdn about Int32.TryParse()

When this method returns, contains the 32-bit signed integer value equivalent to the num

5条回答
  •  爱一瞬间的悲伤
    2021-01-01 09:38

    TryParse() returns a Boolean.

            Int32 testInt;
    
            if (!Int32.TryParse("123", out testInt))
            {
                MessageBox.Show("Is not a Int32!");
                return; // abbrechen
            }
    
            MessageBox.Show("The parst Int32-value is " + testInt);
    

提交回复
热议问题