如何将ListViewItem转换为int [英] How to convert ListViewItem to int

查看:218
本文介绍了如何将ListViewItem转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,



我需要将ListViewItem.SubItems [i]转换为int,if if condition(<> = operator)。



然后你们全部,



Niv

Hey,

I need to convert ListViewItem.SubItems[i] to int, for if condition (<>= operator).

thenk you all,

Niv

推荐答案

ListViewItem.SubItems [i] 的返回值是 ListViewSubItem [ ^ ]。您可以使用此对象的 Text 属性,然后将该值转换为int:

The return value of ListViewItem.SubItems[i] is a ListViewSubItem[^]. You can use the Text property of this object and then convert that value to an int:
string text = yourListViewItem.SubItems[i].Text;
int number;
if (int.TryParse(text, out number))
{
    // Do what you want with 'number'.
}
else
{
    // Not a valid integer.
}


这篇关于如何将ListViewItem转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆