尝试在标签中查看时如何解决IP地址问题 [英] how to solve IP Address problem when try to view it in label

查看:81
本文介绍了尝试在标签中查看时如何解决IP地址问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看我的IP地址不正常时显示如此



您的IP:2001:5ef5:79fb:2c76:3ad7:1999






when view my ip address not normal show like that

Your IP :2001:5ef5:79fb:2c76:3ad7:1999



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace Compn
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "Host Computer : " + Dns.GetHostName();
            foreach (IPAddress adress in Dns.GetHostAddresses(Dns.GetHostName()))
            {
                label2.Text = "Your IP : " + adress;
            }
        }
    }
}

推荐答案

这是你使用的时候IPV6:



https://en.wikipedia.org/wiki/ IPv6 [ ^ ]



IPV4是您正在考虑的协议。查看 Dns.GetHostAddresses(Dns.GetHostName())中的列表是否有一个。如果你的代码都只是在标签上写下并留下旧代码。





您可以通过更改来测试标签行:

It is when you are using IPV6:

https://en.wikipedia.org/wiki/IPv6[^]

IPV4 is the protocal you're thinking of. See if the list in Dns.GetHostAddresses(Dns.GetHostName()) has one. If there are both the your code just writes over the label and leaves it with the old one.


You can test this by changing the label line:
label2.Text += adress + ", ";


这篇关于尝试在标签中查看时如何解决IP地址问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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