小编Ben*_*ton的帖子

How to remove port number from an IP address string

i am trying to separate the IP from the port in a list box. but i am only leaving the port number and ":" how would i make it so the ":" is removed and only the IP is left.

ips look like this:

192.168.0.12:80

192.168.0.2:123

192.168.0.3:1337

  for (int i = 0; i < lb.Items.Count; i++)
        {
            string item = lb.Items[i] as string;
            item = item.Substring(item.LastIndexOf(":"));
            lb.Items[i] = item;
        }
Run Code Online (Sandbox Code Playgroud)

.net c# string listbox

3
推荐指数
2
解决办法
4978
查看次数

标签 统计

.net ×1

c# ×1

listbox ×1

string ×1