Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有带有一些项目的 ComboBox。项目值的默认返回类型 - 字符串。我想知道如何在 ComboBox 中获取所选项目的“Int”类型的值。
显式转换产生错误:指定的转换无效。
谢谢!:)
您可以使用 int.Parse(box.SelectedValue)。如果它给您一个错误,则意味着该值不是整数。在那种情况下,可能值是空的,只设置了文本。