Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when view my ip address not normal show like that

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



C#
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;
            }
        }
    }
}
Posted

1 solution

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:
C#
label2.Text += adress + ", ";
 
Share this answer
 
Comments
Mohamed Ragheb 17-Aug-15 9:54am    
thanks Andy Lanng for answer :0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900