if (submit.C开发者_如何学编程ontent.Equals("Submit"))
I'm trying to test if the content in a button called submit = "submit". However, this code doesn't work.
The type of the Content
property is Object
, so you will be calling the Object.Equals
method rather than the String.Equals
method. The string method compares string values, while the object method only compares the references.
You can just apply the method to the string instead to make it a string comparison instead of a reference comparison:
if ("Submit".Equals(submit.Content))
精彩评论