Solved

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

Posted on 2008-06-19
8
3,441 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 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