자주 사용하는 함수임에도 불구하고 항상 쓸때마다 찾아 본다.. // 16진수로 변환 public string ToHex(int i) { // 대문자 X일 경우 결과 hex값이 대문자로 나온다. string hex = i.ToString("x"); if (hex.Length % 2 != 0) { hex = "0" + hex; } return hex; } // 10진수로 변환 : Long public long ToLong(string hex) { return Convert.ToInt64(hex, 16); } // 10진수로 변환 : Int public int ToDec(string hex) { return Convert.ToInt32(hex, 16); } // 10진수 -> 16진수 Console.Write..
MainThread(UI Thread)가 아닌 Thread가 컨트롤로 접근시 컴파일 에러가 발생한다. 이러한 에러를 Cross Thread Error 라고 한다. 어떻게 보면 불편 하기도 하지만, 보다 안전한 코딩을 컴파일러에서 지원해준다는 점에서 좋은 것 같다. 간단한 툴의 경우는 보통 단일 Thread로 사용이 가능 하나, 약간의 기능을 더 넣고자 한다면 필수적으로 추가 Thread가 필요할 것 이다. (자주 쓰이는 예로, 개별 Thread에서 일련의 작업과정을 textBox에 로그로 기록하는 상황이 있다.) 1. delegate를 선언하여 사용하는 방법 private delegate void delegate_WritetLog(Control ctr, String log); private void Wr..
WinHttp를 사용하기 위해서는 winhttp.dll을 참조 후 프로젝트에서 using 해줘야 한다. 1. C:\Windows\System32\winhttp.dll 을 참조 추가 2. 프로젝트내에서 using WinHttp; 입력 private List GetCookie() { var winHttp = new WinHttpRequest(); winHttp.Open("POST", "임의의 POST URL"); winHttp.SetRequestHeader("Referer", "임의의 Referer URL"); winHttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winHttp.Send("임의의 전달 값"); winHtt..
C# 에서 Thread는 크게 2가지로 나뉜다. 1. 매개인자가 없는 일반적인 쓰레드 2. 매개인자가 있는 쓰레드 약간의 차이가 있으나 두가지 방법 모두 어렵지 않다. 1. 매개인자가 없는 일반적인 쓰레드 private void ThreadStart() { System.Threading.Thread th = new Thread(new ThreadStart(Test)); th.Start(); } private void Test() { Console.WriteLine("Good"); } 2. 매개인자가 있는 쓰레드 private void ThreadStart() { string[] param = { "Param", "Good" }; System.Threading.Thread th = new Thread(ne..
- Total
- Today
- Yesterday