using System;
using System.Net;
using System.Net.Sockets;
namespace
{
public class IPAddress
{
/// <summary>
///
/// </summary>
public static void Main()
{
try
{
Console.WriteLine("input the hostname");
string PHostName = Console.ReadLine();//read hostname
IPHostEntry myAddress = Dns.GetHostEntry(PHostName);//read hostname 's ip
Console.WriteLine("{0}", PHostName); //beacuse ip has a lot of name .ip judge arrary
IPAddress[] myIPAddress =(IPAddress[]) myAddress.AddressList;//??????????????????????有错误??
foreach (IPAddress add in myIPAddress)
Console.WriteLine(add);//take out ip from myipaddress
Console.WriteLine("IP");
string PAddress = Console.ReadLine();
IPHostEntry myHostName = Dns.GetHostEntry(PAddress);
Console.WriteLine("{0}", PAddress);
Console.WriteLine(myHostName.HostName.ToString());
}
catch (SocketException e)
{
Console.WriteLine( e.Message);
}
Console.WriteLine();
Console.ReadLine();
}
}
}错误 2 无法将类型“System.Net.IPAddress[]”转换为“ClassLibrary1.IPAddress[]” D:\ClassLibrary1\ClassLibrary1\Class4.cs 24 42 ClassLibrary1
IPAddress[] myIPAddress =(IPAddress[]) myAddress.AddressList;//??????????????????????有错误??
另个一个错误与上面没有关系的: TcpListener myTcpListener = new TcpListener(36000);//???????????error error error
myTcpListener.Start();
Console.WriteLine("port 36000 is connection for a wiat now");
Socket mySocket=myTcpListener.AcceptSocket();
警告 3 “System.Net.Sockets.TcpListener.TcpListener(int)”已过时:
“This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port)
instead. http://go.microsoft.com/fwlink/?linkid=14202”
D:\ClassLibrary1\ClassLibrary1\networkserver.cs 19 40 ClassLibrary1
TcpListener myTcpListener = new TcpListener(36000);//???????????error error error
using System.Net;
using System.Net.Sockets;
namespace
{
public class IPAddress
{
/// <summary>
///
/// </summary>
public static void Main()
{
try
{
Console.WriteLine("input the hostname");
string PHostName = Console.ReadLine();//read hostname
IPHostEntry myAddress = Dns.GetHostEntry(PHostName);//read hostname 's ip
Console.WriteLine("{0}", PHostName); //beacuse ip has a lot of name .ip judge arrary
IPAddress[] myIPAddress =(IPAddress[]) myAddress.AddressList;//??????????????????????有错误??
foreach (IPAddress add in myIPAddress)
Console.WriteLine(add);//take out ip from myipaddress
Console.WriteLine("IP");
string PAddress = Console.ReadLine();
IPHostEntry myHostName = Dns.GetHostEntry(PAddress);
Console.WriteLine("{0}", PAddress);
Console.WriteLine(myHostName.HostName.ToString());
}
catch (SocketException e)
{
Console.WriteLine( e.Message);
}
Console.WriteLine();
Console.ReadLine();
}
}
}错误 2 无法将类型“System.Net.IPAddress[]”转换为“ClassLibrary1.IPAddress[]” D:\ClassLibrary1\ClassLibrary1\Class4.cs 24 42 ClassLibrary1
IPAddress[] myIPAddress =(IPAddress[]) myAddress.AddressList;//??????????????????????有错误??
另个一个错误与上面没有关系的: TcpListener myTcpListener = new TcpListener(36000);//???????????error error error
myTcpListener.Start();
Console.WriteLine("port 36000 is connection for a wiat now");
Socket mySocket=myTcpListener.AcceptSocket();
警告 3 “System.Net.Sockets.TcpListener.TcpListener(int)”已过时:
“This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port)
instead. http://go.microsoft.com/fwlink/?linkid=14202”
D:\ClassLibrary1\ClassLibrary1\networkserver.cs 19 40 ClassLibrary1
TcpListener myTcpListener = new TcpListener(36000);//???????????error error error
希望大家的问题能够及时的得到解决.