本文介绍了不会工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数字列表框.当我单击数字时,我想在控制台中显示它.有什么原因为什么行不通呢?

Console.WriteLine(Int32.Parse(listBox1.SelectedItems.ToString()));

感谢您的帮助.

I have a listbox of numbers. When I click on the number I want to show it in the console. Is there any reason why this wouldn''t work.

Console.WriteLine(Int32.Parse(listBox1.SelectedItems.ToString()));

Any help is appreciated.

推荐答案



System.Windows.Forms.ListBox+SelectedObjectCollection



那可能不是您所期望的.然后,当您使用Parse函数时,它会引发错误,因为它不是数字值.

我的另一建议是,如果您确信它会起作用,请仅使用Parse方法.否则,请改用TryParse.



That''s probably not what you were expecting. Then, when you used the Parse function, it would have thrown an error because it is not a numeric value.

My other suggestion is only use the Parse methods if you are assured that it will work. Otherwise, use TryParse instead.


这篇关于不会工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:06