您的位置:首页 > 编程语言 > C#

C#基础学习之获取ip与readonly用法小例

2008-05-11 20:52 288 查看

using System;


using System.Collections.Generic;


using System.Text;


using System.Net;




namespace readonly




...{


class workstation




...{


public const string HostName = "lenovo-e590f938";


public readonly string IPAddressString;




public workstation()




...{


IPAddress ipaddress = Dns.GetHostByName("lenovo-e590f938").AddressList[0];


IPAddressString = ipaddress.ToString();


}


}




class Program




...{


static void Main(string[] args)




...{


workstation workstation = new workstation();


Console.WriteLine("The IP Address for '{0}' is {1}",workstation.HostName,workstation.IPAddressString);


}


}


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: