Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-19
8
Medium Priority
?
3,520 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

704 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