본문 바로가기

Programming/C#10

[C#] 같은 문자열 체크 같은 문자열 체크 private bool checkSameStr(string str) { int cnt = 0; for (int i = 0; i = 2) { break; } } if (cnt >= 2) { //3글자 이상 막기 return false; } return true; } 2021. 4. 16.
[C#] 문자열 체크 / 비밀번호 체크 정규식 문자열 체크 (숫자, 영문, 특수문자) (비밀번호 조합 체크) using System.Text.RegularExpressions; private bool checkNumberEnglishSpecialChar(string str) { Regex engRegex = new Regex(@"[a-zA-Z]"); Boolean isMatchEn = engRegex.IsMatch(str); Regex numRegex = new Regex(@"[0-9]"); Boolean isMatchNum = numRegex.IsMatch(str); Regex specialRegex = new Regex(@"[~!@\#$%^&*\()\=+|\\/:;?""']"); Boolean isMatchSpecial = specialRegex.. 2021. 4. 14.
[C#] 비밀번호 공백 체크 비밀번호 공백 체크 (How to check whether input value is included space) using System.Linq; private bool checkSpace(string str) { if (str.Any(x => Char.IsWhiteSpace(x) == true)) { return true; } else { return false; } } 2021. 4. 13.
[C#] SubnetMask 구하기 [C#] SubnetMask 구하기 How to get subnetmask in C# using System.Net; using System.Net.NetworkInformation; private void showSubnetMask() { NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); string subnetMask = string.Empty; foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); foreach (UnicastIPAddressInformation .. 2019. 8. 30.
[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.
[C#/WinForm] 창 크기 조절하기 [C#/WinForm] 윈도우 폼 크기 조절하기윈도우 창 크기 조절하기 속성 - AutoSize false 크기 조절 불가 true 크기 조절 가능 - AutoSizeMode GrowOnly 수동으로 조절가능, 설정된 크기보다 작게 조절은 불가능 GrowAndShrink 폼 비율 유지, 수동으로 조절 불가능 - FormBorderStyle None 폼 외곽 없음, 크기 변경 불가 FixedSingle 폼 외곽 단순 선, 크기 변경 불가 Fixed3D 폼 외곽 3D선, 크기 변경 불가 FixedDialog 폼 외곽 두꺼운 선, 크기 변경 불가 Sizable 크기 변경 가능 (폼 외곽은 fixedsingle과 같음) FixedToolWindow 도구창, 크기 변경 불가능 SizableToolWindow 도구.. 2018. 8. 20.