Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何基于整数从列表框中获取特定行_C#_String_Listbox_Integer_Int - Fatal编程技术网

C# 如何基于整数从列表框中获取特定行

C# 如何基于整数从列表框中获取特定行,c#,string,listbox,integer,int,C#,String,Listbox,Integer,Int,我这里有一个非常基本的列表框,我想根据listbox1.items.count从特定行获取文本;因为这是一个整数 如何获取对应于该整数的行(本质上是行号),并将该行存储到字符串RecentPlayer中 Ex. Line # ListBox Contents Line 0 Some String Line 1 Some Other Line 3 Something Else 请提供填充Listbox的代码它非常长……但这里只有一行playerList.I

我这里有一个非常基本的列表框,我想根据listbox1.items.count从特定行获取文本;因为这是一个整数

如何获取对应于该整数的行(本质上是行号),并将该行存储到字符串RecentPlayer中

Ex.

 Line #    ListBox Contents

 Line 0    Some String

 Line 1    Some Other

 Line 3    Something Else

请提供填充Listbox的代码它非常长……但这里只有一行
playerList.Items.Add(player.Info.Rank.Name+“-”+player.Name)我刚刚想出了如何在更新ToString()选项时正确使用它:P
string value = playerList.Items[index].ToString();