Solved

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

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


private IPAddress localaddr = "127.0.0.1";


myListener = new TcpListener(localaddr,port);


localaddr, i'm stuck here, for debugging.

// Cannot implicitly convert type 'string' to 'System.Net.IPAddress'
0
Comment
Question by:Natural_Demon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21828272

private IPAddress localaddr = IPAddress.Parse("127.0.0.1");
myListener = new TcpListener(localaddr,port);

Open in new window

0
 
LVL 7

Expert Comment

by:AUmidh
ID: 21828278
Try this

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

Expert Comment

by:margajet24
ID: 21828284
IPAddress localaddr =  IPAddress.Parse("127.0.0.1");
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:Natural_Demon
ID: 21828494
thanks you for the promp rely,

IPAddress localaddr =  IPAddress.Parse("127.0.0.1"

how to get addres of localhost?
0
 
LVL 18

Accepted Solution

by:
philipjonathan earned 125 total points
ID: 21828558
localhost is always '127.0.0.1'
0
 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 21828573

//For parsing the string to IP
IPAddress ip =  IPAddress.Parse("127.0.0.1")
 
// 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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
orderby list (from Json) 1 44
array not updating 8 42
Send parameters via datatable ajax call 4 48
Pdf not loading 2 40
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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