What is the difference between Convert.ToBoolean(string) and Boolean.Parse(string)?

后端 未结 3 1450
北恋
北恋 2020-12-11 00:16

What is the difference between the two methods

Convert.ToBoolean()

and

Boolean.Parse()?

Is there any reason to u

3条回答
  •  暖寄归人
    2020-12-11 00:40

    Boolean.Parse() will convert a string representation of a logical boolean value to a boolean value. Convert.ToBoolean() has multiple overloads that will convert primitive types to their boolean equivalent.

    Most, if not all, of the primitive types in C# have an associated *.Parse/Convert.To* method that serve the same purpose as Boolean.Parse()/Convert.ToBoolean().

提交回复
热议问题