본문 바로가기

전체 글

C# 역문자열 StreamReader file = new StreamReader("input.txt"); int size = Int32.Parse(file.ReadLine()); List list = new List(); while (!file.EndOfStream) { list.Add(file.ReadLine()); } for (int i = 0; i < list.Count-1; i++) { String rev = new String(list[i].ToCharArray().Reverse().ToArray()); for(int j=i+1;i 더보기
C# 문자열, 숫자, 영어 검사 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace number2 { class Program { static class Constants { public const bool DebugFlag = true; } static void D(string log) { if (Constants.DebugFlag) Console.WriteLine(log); } static void Main(string[] args) { if ((args.Length == 0) || ((args.Length==1) && (args[0].Length>50))) {.. 더보기
C# 구조체, 클래스, 리스트 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace number4 { class Program { public struct rentcar { public string carID; public string carTime1; //대여 public string carTime2; //반납 public int renttime; public rentcar(string _carID, string _carTime1, string _carTime2) { carID = _ca.. 더보기
C# 비트연산 http://www.csharpstudy.com/Tip/Tip-byte-bit.aspx // (// (1) 한 byte 를 Hex 문자로 변환하는 방법법 byte b1 = 0xFE; string hex1 = b1.ToString("X2"); // (2) byte[] 을 Hex 문자열로 변환하는 방법법 byte[] bytes = new byte[] { 0xA1, 0xB2, 0xC3, 0x11, 0x2F }; string h = string.Concat(Array.ConvertAll(bytes, byt => byt.ToString("X2"))); // 혹은은 // h = BitConverter.ToString(bytes).Replace(""--", "");; // (3) 한 Hex 문자를 byte 로 변환하.. 더보기
C# 해시테이블 //생성 Hashtable hashtable = new Hashtable(); //자료 추가 ( 박싱이 일어남) hashtable.Add("Data1", new HongsClass() { Name = "홍진현1", intCount = 1 }); hashtable.Add("Data2", new HongsClass() { Name = "홍진현2", intCount = 2 }); //자료 검색 if (hashtable.ContainsKey("Data1").Equals(true)) { HongsClass temp = hashtable["Data1"] as HongsClass; (언박싱 처리) Console.WriteLine(temp.Name); } //Loop 전체 순회출력 foreach (string NowK.. 더보기
C# Dictionary 딕셔너리 //생성- 제네릭 기반 Dictionary dictionary = new Dictionary(); //자료추가 dictionary.Add("Data1", new HongsClass() { Name = "홍진현1", intCount = 1 }); dictionary.Add("Data2", new HongsClass() { Name = "홍진현2", intCount = 2 }); //자료검색 if (dictionary.ContainsKey("Data1").Equals(true)) { Console.WriteLine(dictionary["Data1"].Name); } //Loop 전체 순회출력 foreach (HongsClass NowData in dictionary.Values) { Console.Write.. 더보기
C# 리스트 조회, 리스트 정렬 StreamReader file = new StreamReader("input.txt"); int size = Int32.Parse(file.ReadLine()); List list = new List(); while (!file.EndOfStream) { list.Add(file.ReadLine()); } //list.Sort(); List newlist = new List(); for (int i = 0; i < list.Count; i++) { if (!newlist.Contains(list[i])) { newlist.Add(list[i]); } } newlist.Sort(delegate(string a, string b) { if (a.Length < b.Length) return -1; else.. 더보기
C# 문자열 파싱 parsing split StreamReader file = new StreamReader("input.txt"); int size = 0; //List list = new List(); while (!file.EndOfStream) { string s=file.ReadLine(); string[] token = s.Split(' '); size += token.Length; } file.Close(); 더보기
C# 문자열 Mid,Left,Right public string Mid(string sString, int nStart, int nLength) { string sReturn; --nStart; if (nStart sString.Length) { nLength = sString.Length; } sReturn = sString.Substring(sString.Length - nLength,nLength); return sReturn; } 더보기
C# lock using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace @lock { class Account { private Object thisLock = new Object(); int balance; Random r = new Random(); public Account(int initial) { balance = initial; } int Withdraw(int amount) { // This condition never is true unless the lock statement // is comm.. 더보기