c#  why?,howto? Cannot implicitly convert type 'string' to 'System.Net.IPAddress'

Posted on 2008-06-19
Last Modified: 2008-08-13
private IPAddress localaddr = Dns.GetHostEntry(textBox1.Text).AddressList[0].ToString();//"";

private IPAddress localaddr = "";

myListener = new TcpListener(localaddr,port);

localaddr, i'm stuck here, for debugging.

// Cannot implicitly convert type 'string' to 'System.Net.IPAddress'
Question by:Natural_Demon
LVL 18

Expert Comment

ID: 21828272

private IPAddress localaddr = IPAddress.Parse("");

myListener = new TcpListener(localaddr,port);

Open in new window


Expert Comment

ID: 21828278
Try this

private IPAddress localaddr = IPAddress.Parse("");
LVL 10

Expert Comment

ID: 21828284
IPAddress localaddr =  IPAddress.Parse("");
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.


Author Comment

ID: 21828494
thanks you for the promp rely,

IPAddress localaddr =  IPAddress.Parse(""

how to get addres of localhost?
LVL 18

Accepted Solution

philipjonathan earned 125 total points
ID: 21828558
localhost is always ''

Expert Comment

by:Rahul Goel
ID: 21828573

//For parsing the string to IP

IPAddress ip =  IPAddress.Parse("")

// To get the localhost IP

IPHostEntry iphost = Dns.GetHostByName(Dns.GetHostName());

IPAddress[] addr = iphost.AddressList;

for (int i = 0; i < addr.Length; i++)


                listBox1.Items.Add(string.Format("IP Address {0}: {1} ", i, addr[i].ToString()));


Open in new window


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now