본문 바로가기

Programming/C#10

[C#] DNS서버 구하기 [C#] DNS 서버 구하기 How to get DNS in C# using System.Net; using System.Net.NetworkInformation; private void showDnsServer() { NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); ArrayList dnsAddrList = new ArrayList(); foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); if (adapter.OperationalStatus == Operation.. 2019. 8. 29.
[C#] Gateway 구하기 [C#] Gateway 구하기 How to get gateway in C# using System.Net.NetworkInformation; privite void showGateway() { NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); string gateway = string.Empty; foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); GatewayIPAddressInformationCollection addresses = adapterProperties.. 2019. 8. 28.
[C#] 로컬 IP 주소 구하기 [C#] 로컬 IP 주소 구하기 How to get ip address in C# using System.Net; private void ShowIP() { IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); string IP4Addr = string.Empty; foreach (Ipaddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ip4Addr = ip.ToString(); Console.WriteLine(ip4Addr); } } } 2019. 8. 27.
[C#] 수행시간 구하기 [C#] 수행시간 구하기 실행시간 구하기가끔 수행시간을 기록하거나 얼마나 소요되는지 검색해야할 경우가 있음. 실행시간을 구하는 방법은 DateTime.Now, TimeSpan, Stopwatch등을 사용하면 됨 stackoverflow에서 대용량 데이터를 핸들링 하는 경우 Stopwatch가 더 빠르다고함.실제 2500여건 조회 결과, Stopwatch가 Datetime과TimeSpan을 쓴 것 보다 0.003정도로 미세하게 빠름 제일 빠른건 DateTime.UtcNow Stopwatch 사용법 using System.Diagnostics; Stopwatch SW = new Stopwatch();string sTime1, sTime2; //초기화SW.Reset(); //SW시작SW.Start();//SW.. 2018. 8. 21.