codekiller의 등록된 링크

키자드에 등록된 총 1398개의 포스트를 확인하실 수 있습니다.

Tistory

[C#/General] Enumerable.ElementAt 사용 예제.

> 지정된 인덱스 요소를 반환. public class Example { public static void Main() { Console.Write("> \n"); string[] names = { "CodeZero", "CodeOne", "CodeTwo", "CodeThree"}; string name = names.ElementAt(1); Console.WriteLine("The name chosen is '{0}'.", name); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }

Tistory

[(8월17일)프로젝트 공유] (주)휴먼인러브 ..... 닷넷업무

해당 업체 메일링 리스트에 추가되어 제 개인 메일로 오는 프로젝트들입니다. 프리랜서들에게는 누락되는 프로젝트 없이 볼 수있는 공간이 되었으면 하고, 업체들에게는 수월한 공유가 되었으면 좋겠네요. 문제가 되는 부분 있다면 댓글 달아주시면 삭제하도록 하겠습니다. 1..(을지로) IBK 파생상품통합 운용시스템 등 급 : 중급 1명 기 간 : 8월 16일부터 2023.02.28 (매년 자동연장) 스 킬 : C#, oracle 기 타 : 금융권 경력자 우대 2.(을지로) ERP 시스템 컨설턴트 모집 기 간 : 즉시부터 6개월 (6개월단위 자동연장) 등 급 : 고급 12명 스 킬 : 영업, 물류, 구매, 자재, 생산, 원가 모듈 구축/설계 경험자 (각분야별 2명) 3.(구미) LGD 자동 판정시스템 운영 기 간 :..

Tistory

[(2022-08-19)프로젝트공유] (주)보람아이티

해당 업체 메일링 리스트에 추가되어 제 개인 메일로 오는 프로젝트들입니다. 프리랜서들에게는 누락되는 프로젝트 없이 볼 수있는 공간이 되었으면 하고, 업체들에게는 수월한 공유가 되었으면 좋겠네요. 문제가 되는 부분 있다면 댓글 달아주시면 삭제하도록 하겠습니다. 보람아이티에서 프로젝트 정보를 드립니다. 안녕하세요. (주)보람아이티의 백광현 입니다. 하기의 프로젝트 정보를 참조하시고 가능하신 프로젝트가 있으면 말씀해 주시고 최신 이력서(희망단가 기재)를 보내 주시기 바랍니다. 다시 연락 드리겠습니다. 행복하시고 즐거운 하루 되세요. - 기 – 프로젝트 명 필요기술 투입기간 기술등급 근무지 모집인원 LGD A6 대응 차세대 ECS Application 개발(UI 영역)_설비제어 C#(필수), WPF(필수), W..

Tistory

[C#/General] Enumerable.SequenceEqual 사용예제.

> 두 소스 시퀀스의 길이가 같고, 상응하는 요소가 서로 같으면 true이고, 그렇지 않으면 false. > 객체내의 Value들의 같음을 비교하는 메서드가 아님에 주의해야함. public class Example { public static void Main() { Console.Write("> \n"); Code code1 = new Code { Name = "CodeA", Count = 2 }; Code code2 = new Code { Name = "CodeB", Count = 8 }; // codes의 두 리스트를 생성한다. List codes1 = new List { code1, code2 }; List codes2 = new List { code1, code2 }; bool equal = c..

Tistory

[Json2csharp] json형식을 C# 클래스로 변환 등.

https://json2csharp.com/ Convert JSON to C# Classes Online - Json2CSharp Toolkit json2csharp.com Json 스트링을 C# 클래스로 변경하려고 할때, Json 스트링이 Array안에 Array안에 겹겹이 되어 있을 경우,,,,, 눈이 매우 아프죠~~ 위 싸이트 활용해보세요^^ 위 싸이트 사용하면 C#클래스로 변환 가능합니다. 약간의 자료형 타입 변경이 필요할때도 있지만, 매우 유용해서 즐겨 사용합니다.

Tistory

[(8월17일)프로젝트 공유] (주)휴먼인러브 .... C계열.

해당 업체 메일링 리스트에 추가되어 제 개인 메일로 오는 프로젝트들입니다. 프리랜서들에게는 누락되는 프로젝트 없이 볼 수있는 공간이 되었으면 하고, 업체들에게는 수월한 공유가 되었으면 좋겠네요. 문제가 되는 부분 있다면 댓글 달아주시면 삭제하도록 하겠습니다. 1.(역삼역)GS넷비전 2022년 쿠폰시스템 운영 계약 등 급 : 고급1명(10년차 이상) 기 간 : 2022.09.01 ~ 2022.12.31(연단위 연장 계약) 담당업무 : GS넷비전 쿠폰시스템 운영 및 유지보수 업무를 수행, 문의에 대한 응대와 시스템 장애에대한 처리와 개선 사항에 대한 수정/개발을 주요 업무로 진행 스 킬 : Java, javascript, sql, ProC, JSP 2.(을지로) ERP 시스템 컨설턴트 모집 기 간 : 즉시부..

Tistory

[C#/General] Enumerable.DefaultIfEmpty 메서드의 사용.

> defaultValue가 비어 있으면 source가 들어 있는 IEnumerable이고, defaultValue가 그렇지 않으면 defaultValue source 를 반환하는 함수입니다. public class Example { public static void Main() { Console.Write("> \n"); Code defaultCode = new Code { Name = "Default Code", Count = 0 }; List code1 = new List{ new Code { Name="CodeA", Count=8 }, new Code { Name="CodeB", Count=4 }, new Code { Name="CodeC", Count=1 } }; foreach (Code cod..

Tistory

[C#/General] Enumerable.Empty 사용 예제.

> 비어있는 IEnumerable을 반환. public class Example { public static void Main() { Console.Write("> \n"); IEnumerable empty = Enumerable.Empty(); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }

Tistory

[C#/Linq][Join C#] join … in … on … equals … 사용 예제.

public class Example { public static void Main() { Console.Write("> \n"); List codes = new List { new Code { Name = "CodeA", CategoryId = 0 }, new Code { Name = "CodeB", CategoryId = 0 }, new Code { Name = "CodeC", CategoryId = 1 }, new Code { Name = "CodeD", CategoryId = 1 }, new Code { Name = "CodeE", CategoryId = 2 }, }; List keyCategories = new List { new KeyCategory { Id = 0, CategoryName =..

Tistory

[C#/Linq] GroupBy 절 사용법.

public class Example { public static void Main() { Console.Write("> \n"); // Create a list of pets. List petsList = new List{ new Pet { Name="CodeA", Age=8.3 }, new Pet { Name="CodeB", Age=4.9 }, new Pet { Name="CodeC", Age=1.5 }, new Pet { Name="CodeD", Age=4.3 } }; // Math.Floor(pet.Age)를 이용하여 그룹핑. var query = petsList.GroupBy( pet => Math.Floor(pet.Age), pet => pet.Age, (baseAge, ages) => new..

Tistory

[C#/Linq] GroupBy 절 (기본샘플)

public class Example { public static void Main() { Console.Write("> \n"); List numbers = new List() { 55, 64, 300, 74, 1987, 8, 299, 429, 546, 308 }; IEnumerable query = from number in numbers group number by number % 2; foreach (var group in query) { Console.WriteLine(group.Key == 0 ? "\nEven numbers:" : "\nOdd numbers:"); foreach (int i in group) Console.WriteLine(i); } Console.WriteLine(Syste..

Tistory

[C#/Linq] Enumerable.GroupJoin 사용 예제.

> 키가 같은지 여부에 따라 두 시퀀스의 요소를 연관시키고 결과를 그룹화. public class Example { public static void Main() { Console.Write("> \n"); Code kim = new Code { Name = "Mr.Kim" }; Code lee = new Code { Name = "Mr.Lee" }; Code choi = new Code { Name = "Mrs.Choi" }; // 예약어를 사용할때는 @ 붙여서 사용. Keyword @double = new Keyword { Name = "double", Owner = lee }; Keyword @int = new Keyword { Name = "int", Owner = lee }; Keyword @c..

Tistory

[C#/Linq] Queryable.GroupJoin 사용 예제.

> 키가 같은 두 시퀀스의 요소를 그룹화합니다. public class Example { public static void Main() { Console.Write("> \n"); Code kim = new Code { Name = "Mr.Kim" }; Code lee = new Code { Name = "Mr.Lee" }; Code choi = new Code { Name = "Mrs.Choi" }; // 예약어를 사용할때는 @ 붙여서 사용. Keyword @double = new Keyword { Name = "double", Owner = lee }; Keyword @int = new Keyword { Name = "int", Owner = lee }; Keyword @char = new Keywo..

Tistory

[C#/Linq] Enumerable.Join 사용 예제.

> 일치하는 키를 기준으로 두 시퀀스의 요소를 연관. public class Example { public static void Main() { Console.Write("> \n"); Code kim = new Code { Name = "Mr.Kim" }; Code lee = new Code { Name = "Mr.Lee" }; Code choi = new Code { Name = "Mrs.Choi" }; // 예약어를 사용할때는 @ 붙여서 사용. Keyword @double = new Keyword { Name = "double", Owner = lee }; Keyword @int = new Keyword { Name = "int", Owner = lee }; Keyword @char = new Ke..

Tistory

[C#/Linq] Queryable.Join 사용 예제.

> 일치하는 키를 기준으로 두 시퀀스의 요소를 연관 public class Example { public static void Main() { Console.Write("> \n"); Code kim = new Code { Name = "Mr.Kim" }; Code lee = new Code { Name = "Mr.Lee" }; Code choi = new Code { Name = "Mrs.Choi" }; // 예약어를 사용할때는 @ 붙여서 사용. Keyword @double = new Keyword { Name = "double", Owner = lee }; Keyword @int = new Keyword { Name = "int", Owner = lee }; Keyword @char = new Key..

Tistory

[C#/Linq] Queryable.Take 사용 예제.

public class Example { public static void Main() { Console.Write("> \n"); int[] grades = { 59, 82, 70, 56, 92, 98, 85 }; IEnumerable topThree = grades.AsQueryable().OrderByDescending(grade => grade).Take(3); Console.WriteLine("상위 3개 등급은 :"); foreach (int grade in topThree) Console.WriteLine(grade); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console..

Tistory

[C#/Linq] Enumerable.TakeWhile 사용 예제

public class Example { public static void Main() { Console.Write("> \n"); string[] fruits = { "apple", "passionfruit", "banana", "mango", "orange", "blueberry", "grape", "strawberry" }; IEnumerable query = fruits.TakeWhile((fruit, index) => fruit.Length >= index); foreach (string fruit in query) { Console.WriteLine(fruit); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press..

Tistory

[C#/Linq] Queryable.TakeWhile 사용 예제

public class Example { public static void Main() { Console.Write("> \n"); string[] fruits = { "apple", "banana", "mango", "orange", "passionfruit", "grape" }; // orange를 찿을때까지 출력. IEnumerable query = fruits.AsQueryable() .TakeWhile(fruit => String.Compare("orange", fruit, true) != 0); foreach (string fruit in query) Console.WriteLine(fruit); Console.WriteLine(System.Environment.NewLine); Console..

Tistory

[C#/Linq] Enumerable.SkipWhile 사용 예제.

public class Example { public static void Main() { Console.Write("> \n"); int[] amounts = { 5000, 2500, 9000, 8000,6500, 4000, 1500, 5500 }; // 요소가 조건을 충족하지 않을 때까지 조건자 함수를 기반으로 하여 요소를 건너뜁니다. IEnumerable query = amounts.SkipWhile((amount, index) => amount > index * 1000); foreach (int amount in query) { Console.WriteLine(amount); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine(..

Tistory

[C#/Linq] Queryable.SkipWhile 사용 예제

public class Example { public static void Main() { Console.Write("> \n"); int[] amounts = { 5000, 2500, 9000, 8000,6500, 4000, 1500, 5500 }; // 요소가 조건을 충족하지 않을 때까지 조건자 함수를 기반으로 하여 요소를 건너뜁니다. IEnumerable query = amounts.AsQueryable() .SkipWhile((amount, index) => amount > index * 1000); foreach (int amount in query) Console.WriteLine(amount); Console.WriteLine(System.Environment.NewLine); Console..

Tistory

[C#/Linq] Enumerable.Take 사용 예제.

public class Example { public static void Main() { Console.Write("> \n"); int[] grades = { 59, 82, 70, 56, 92, 98, 85 }; IEnumerable topThreeGrades = grades.OrderByDescending(grade => grade).Take(3); Console.WriteLine("상위 3개 등급 : "); foreach (int grade in topThreeGrades) { Console.WriteLine(grade); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Conso..

Tistory

[C#/Linq] Enumerable.Skip 사용법.

public class Example { public static void Main() { Console.Write("> \n"); int[] grades = { 59, 82, 70, 56, 92, 98, 85 }; IEnumerable codeGrades = grades.OrderByDescending(g => g).Skip(4); Console.WriteLine("상위 4개를 제외한 등급출력 : "); foreach (int grade in codeGrades) { Console.WriteLine(grade); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKe..

Tistory

[C#/Linq] Querable.Skip 사용 예제

public class Example { public static void Main() { Console.Write("> \n"); int[] grades = { 59, 82, 70, 56, 92, 98, 85 }; // 내림차순으로 등급을 정렬하고, 처음 세 개를 제외하고 모두 출력. IEnumerable codeGrades = grades.AsQueryable().OrderByDescending(g => g).Skip(3); Console.WriteLine("상위 3개를 제외한 등급 출력 :"); foreach (int grade in codeGrades) Console.WriteLine(grade); Console.WriteLine(System.Environment.NewLine); Console...

Tistory

[C#/Linq] Zip 절 이해하기.

> Zip 구문은 동일한 시퀀스의 요소들의 튜플을 반화합니다. public class Example { public static void Main() { Console.Write("> \n"); // An int array with 7 elements. IEnumerable numbers = new[] { 1, 2, 3, 4, 5, 6, 7 }; // A char array with 6 elements. IEnumerable letters = new[] { "Code", "killer", "Codekiller", "house", "horse", "letters" }; foreach ((int number, string letter) in numbers.Zip(letters)) { Console.Write..

Tistory

[C#/Linq] Select절, SelectMany 절 (출력예제)

public class Example { public static void Main() { Console.Write("> \n"); List samples = new() { new Samples { LstTestString = new List { "no1", "no2", "no3", "no4" }}, new Samples { LstTestString = new List { "no5", "no6", "no7" }}, new Samples { LstTestString = new List { "no8", "no9", "no10", "no11", "no12" }}, new Samples { LstTestString = new List { "no13", "no14", "no15", "no16" }} }; IEnu..

Tistory

[C#/Linq] Enumerable.Chunk 사용법

public class Example { public static void Main() { Console.Write("> \n"); int i = 1; foreach (int[] chunk in Enumerable.Range(0, 10).Chunk(3)) { Console.WriteLine($"Chunk {i++}:"); foreach (int item in chunk) { Console.WriteLine($" {item}"); } Console.WriteLine(); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }

Tistory

[C#/Linq] Where절에서 Contains함수이용하여 필터링.

public class Example { public static void Main() { Console.Write("> \n"); List markets = new List { new CodeStore { Name = "CK's", Items = new string[] { "kiwi", "cheery", "banana" } }, new CodeStore { Name = "PK's", Items = new string[] { "melon", "mango", "olive" } }, new CodeStore { Name = "ZK's", Items = new string[] { "kiwi", "apple", "orange" } }, }; // items에 특정 문자열이 포함되어 있는 것 찿기. IEnumer..

Tistory

[C#/Linq] Select 절 기본 이해.

public class Example { public static void Main() { Console.Write("> \n"); List words = new() { "code", "killer", "the", "day" }; var query = from word in words select word.Substring(0, 1); foreach (string s in query) Console.WriteLine(s); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }

Tistory

[C#/Linq] Where절에 수량자 함수 이용하기. (필터링)

public class Example { public static void Main() { Console.Write("> \n"); List markets = new List { new CodeStore { Name = "CK's", Items = new string[] { "kiwi", "cheery", "banana" } }, new CodeStore { Name = "PK's", Items = new string[] { "melon", "mango", "olive" } }, new CodeStore { Name = "ZK's", Items = new string[] { "kiwi", "apple", "orange" } }, }; // items의 길이가 모두 5인것을 충족하는지 검사하기 위한 All..

Tistory

[C#/Linq] Where에서 Any() 수량자 함수 사용하기.

public class Example { public static void Main() { Console.Write("> \n"); List markets = new List { new CodeStore { Name = "CK's", Items = new string[] { "kiwi", "cheery", "banana" } }, new CodeStore { Name = "PK's", Items = new string[] { "melon", "mango", "olive" } }, new CodeStore { Name = "ZK's", Items = new string[] { "kiwi", "apple", "orange" } }, }; // items의 시작문자가 "o"로 시작하는 수량자 함수(Any)를 ..

Tistory

[C#/Linq] Intersect 사용예제.

using System.Linq; using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); string[] words = { "this", "code", "killer", "killer", "code", "funny" }; string[] words2 = { "this", "AA", "killer", "BB", "code", "CC" }; IEnumerable query = from code in words.Intersect(words2) select code; foreach (var str in query) { Console.WriteLine(str); } Console.WriteLine..

Tistory

[C#/Linq] Union 사용예제

public class Example { public static void Main() { Console.Write("> \n"); string[] words1 = { "Mercury", "Venus", "Earth", "Jupiter" }; string[] words2 = { "Mercury", "Earth", "Mars", "Jupiter" }; IEnumerable query = from unionexam in words1.Union(words2) select unionexam; foreach (var str in query) { Console.WriteLine(str); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Pre..

Tistory

[C#/Linq] 문자열 필터링 예제

public class Example { public static void Main() { Console.Write("> \n"); string[] words = { "this", "that", "code", "dog", "cat" }; IEnumerable query = from word in words where word.Length == 3 select word; foreach (string str in query) Console.WriteLine(str); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }

Tistory

[C#/Linq] Except 사용 예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); string[] developer1 = { "CodeKiller", "CodeZero", "CodeJenifer", "CodeCapture" }; string[] developer2 = { "CodeKiller", "CodeJenifer", "CodeBeta", "CodeCapture" }; IEnumerable query = from developer in developer1.Except(developer2) select developer; foreach (var str in query) { Console.WriteLine(str)..

Tistory

[C#/Linq] ExceptBy 사용 예제.

using System.Linq; using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); List cars = new List(); cars.Add(new Car() { CarCode = 1, CarType = 101 }); cars.Add(new Car() { CarCode = 1, CarType = 101 }); cars.Add(new Car() { CarCode = 2, CarType = 101 }); cars.Add(new Car() { CarCode = 3, CarType = 102 }); cars.Add(new Car() { CarCode = 3, CarType = 102 })..

Tistory

[C#/Linq] 1차 내림차순 정렬

> orderby descending 절을 사용하여 문자열을 첫 글자의 내림차순으로 정렬. using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); string[] words = { "this", "code", "killer", "very", "funny" }; IEnumerable query = from word in words orderby word.Substring(0, 1) descending select word; foreach (string str in query) Console.WriteLine(str); Console.WriteLine(System.Environment.New..

Tistory

[C#/Linq] Distinct 사용예제.

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); string[] words = { "this", "code", "killer", "killer", "code", "funny" }; IEnumerable query = from planet in words.Distinct() select planet; foreach (var str in query) { Console.WriteLine(str); } Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press any key to exit"); Console.ReadKe..

Tistory

[C#/Linq] DistinctBy 사용예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); List cars = new List(); cars.Add(new Car() { CarCode = 1, CarType = 101 }); cars.Add(new Car() { CarCode = 1, CarType = 101 }); cars.Add(new Car() { CarCode = 2, CarType = 101 }); cars.Add(new Car() { CarCode = 3, CarType = 102 }); cars.Add(new Car() { CarCode = 3, CarType = 102 }); IEnumerable disti..

Tistory

[C#/Linq] SelectMany 사용 예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); CodeOwner[] petOwners = { new CodeOwner { Name="Code Killer", Codes = new List{ "linq", "foreach" } }, new CodeOwner { Name="Code Killer2", Codes = new List{ "string", "int" } }, new CodeOwner { Name="Code Killer3", Codes = new List{ "switch", "dowhile" } } }; // SelectMany로 쿼리. IEnumerable query1 = ..

Tistory

[C#/Linq] 문자열의 길이에 따른 1차 오름차순 정렬

> 문자열 길이의 오름차순으로 정렬하는 방법 using System.Xml.Linq; public class Example { public static void Main() { Console.Write("> \n"); string[] words = { "this", "code", "killer", "very", "funny" }; // 문자열 길이로 정렬. IEnumerable query = from word in words orderby word.Length select word; foreach (string str in query) Console.WriteLine(str); Console.WriteLine(System.Environment.NewLine); Console.WriteLine("Press..

Tistory

[C#/Linq] Linq의 into 키워드의 사용예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("IEnumerable 의 사용 \n"); List customers = new List(); customers.Add(new Customer() { City = "Seoul", FirstName = "Code", LastName = "Killer" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Code1", LastName = "Killer1" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Code2", LastN..

Tistory

[C#/Linq] Join 문의 사용 예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("IEnumerable 의 join 키워드 사용 \n"); List customers = new List(); customers.Add(new Customer() { City = "Seoul", FirstName = "Code", LastName = "Killer" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Code1", LastName = "Killer1" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Code..

Tistory

[C#/Linq] 표준쿼리 및 메서드방식 쿼리(확장메서드)

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("표준 쿼리 연산자 확장 메서드 \n"); int[] numbers = { 2, 3, 5, 11, 13, 15, 16, 20 }; // 쿼리구문 IEnumerable 표준쿼리 = from num in numbers where num % 2 == 0 orderby num select num; // 메서드구문. IEnumerable 메서드구문쿼리 = numbers.Where(num => num % 2 == 0).OrderBy(n => n); foreach (int i in 표준쿼리) { Console.Write(i + " "); } Console.Wri..

Tistory

[C#/Linq] IEnumerableT<> 변수의 사용 (LINQ 쿼리)

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("IEnumerable 의 사용 \n"); List customers = new List(); customers.Add(new Customer() { City = "Seoul", FirstName = "Code", LastName = "Killer" }); customers.Add(new Customer() { City = "Busan", FirstName = "Dragon", LastName = "Ball" }); IEnumerable customerQuery = from cust in customers where cust.City == "Seou..

Tistory

[C#/Linq] Linq 그룹절(group) 사용 예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("IEnumerable 의 그룹절(group) 사용 \n"); List customers = new List(); customers.Add(new Customer() { City = "Seoul", FirstName = "Code", LastName = "Killer" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Code1", LastName = "Killer1" }); customers.Add(new Customer() { City = "Seoul", FirstName = "Co..

Tistory

[C#/Linq] Linq 기본 예제

public class Example { public static void Main() { Console.Write("Linq 기본예제 \n"); int[] numbers = { 97, 92, 81, 60 }; // Linq 표현식에 의한 Collection 추출. IEnumerable numberQuery = from number in numbers where number > 80 select number; // 쿼리 실행. foreach (int i in numberQuery) { Console.Write(i + " "); } } }

Tistory

[C#/Linq] Linq to Xml 예제

using System.Xml.Linq; public class Example { public static void Main() { Console.Write("Linq to XML 예제 \n"); var filename = "Order.xml"; var currentDirectory = Directory.GetCurrentDirectory(); var OrderFilepath = Path.Combine(currentDirectory, filename); XElement Order = XElement.Load(OrderFilepath); // Linq 형식 IEnumerable partNos = from item in Order.Descendants("Item") select (string)item.Att..

Tistory

[Util] freecommander (Desktop 유틸 소개합니다.)

많은 분들이 알고계시겠지만,, Desktop 프로그램 중에 유료 아니고, 단축키 편한 프로그램 소개합니다. FreeCommander인데요...업데이트도 현재까지 매우 잘 이루어지고 있고, 기능들도 참으로 훌륭합니다. 개발업무에 많은 도움이 될꺼라 보구요. 기능 설명은 패쓰하도록 하겠습니다. 설치해보면 눈에 확 들어와서 따로 설명이 필요가 없는 프로그램 입니다. (제가 잘 사용하는 메뉴는 각 폴더 즐겨찿기, F5(복사), F7(새폴더 만들기) 이정도 ㅋ) https://freecommander.com/en/downloads/ Downloads Downloads FreeCommander XE 2022 Build 861 32-bit public FreeCommander XE 64-bit is currently..

Tistory

[C#/General] Dictionary<TKey,TValue> 예제.

using System.Collections; public class Example { public static void Main() { Dictionary dicProgram = new Dictionary(); // dictionary에 key/value 추가합니다. dicProgram.Add("red", "red.exe"); dicProgram.Add("blue", "blue.exe"); dicProgram.Add("gray", "gray.exe"); dicProgram.Add("black", "black.exe"); // txt로 이미 추가된 Key 가 있으므로 Exception 처리됩니다. try { dicProgram.Add("txt", "winword.exe"); } catch (Argumen..

Tistory

[C#/General] LINQ를 이용한 Collection 예제

public class Example { public static void Main() { ShowLINQ_Collections(); } private static void ShowLINQ_Collections() { List codekillers = GetValues(); // LINQ를 이용한 Collection var retValues = from theCodekiller in codekillers where theCodekiller.Age < 22 orderby theCodekiller.Name select theCodekiller; foreach (Codekiller value in retValues) { Console.WriteLine(value.Name + " " + value.Age); }..

Tistory

[C#/General] List<T> 사용법 예제

using System.Text; public class Example { public static void Main() { DisplayListT(); } private static void DisplayListT() { var theCollections = new List { new Codekiller() { Name="honggildong", Age=47}, new Codekiller() { Name="superman", Age=25}, new Codekiller() { Name="batman", Age=0}, new Codekiller() { Name="catman", Age=3} }; foreach (Codekiller col in theCollections) { Console.WriteLine..

Tistory

[C#/General] ArrayList 사용예제.

using System.Collections; public class Example { public static void Main() { // ArrayList 생성 ArrayList arrayList = new ArrayList(); arrayList.Add("Hello"); arrayList.Add("CodeKiller"); arrayList.Add("^^"); // ArrayList 의 속성 출력. Console.WriteLine("arrayList"); Console.WriteLine(" Count: {0}", arrayList.Count); Console.WriteLine(" Capacity: {0}", arrayList.Capacity); Console.Write(" Values:"); Pri..

Tistory

[C#/General] Task.WhenAny 이용한 비동기 완료처리.

using System.Diagnostics; HttpClient s_client = new() { MaxResponseContentBufferSize = 1_000_000 }; IEnumerable s_urlList = new string[] { "https://docs.microsoft.com", "https://docs.microsoft.com/aspnet/core", "https://docs.microsoft.com/azure", "https://docs.microsoft.com/azure/devops", "https://docs.microsoft.com/dotnet", "https://docs.microsoft.com/dynamics365", "https://docs.microsoft.com/e..

Tistory

[C#/General] Mutiple File Access (async/await)

> Main에서 비동기 사용 (Main에서 await 사용) using System.Text; public class Example { public async static Task Main() { ProcessMulitpleWritesAsync().GetAwaiter().GetResult(); } public async static Task ProcessMulitpleWritesAsync() { IList sourceStreams = new List(); try { // Testfolder 생성 string folder = Directory.CreateDirectory("Testfolder").Name; IList writeTaskList = new List(); // 10개의 파일을 Async로 생성...

Tistory

[C#/General] Reflection (선언부에 [메타]특성넣기)

> 어셈블리, 모듈(클래스 및 속성)에 하나 이상의 특성을 적용가능 using System.Text; public class Example { public static void Main() { PrintAuthorInfo(typeof(FirstClass)); PrintAuthorInfo(typeof(SecondClass)); PrintAuthorInfo(typeof(ThirdClass)); } private static void PrintAuthorInfo(System.Type t) { // 리플렉션을 사용하여 속성정보가져오기. System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t); // Reflection. // 속정정보 출력하기. fo..

Tistory

[C#/General] 문자열비교 (Equals, Compare)

public class Example { public static void Main() { string txt1 = @"codekiller"; string txt2 = @"Codekiller"; bool result = txt1.Equals(txt2); Console.WriteLine($"Equals 을 이용한 비교: 와 는 {(result ? "동일하다." : "동일하지 않다.")}"); result = txt1.Equals(txt2, StringComparison.Ordinal); Console.WriteLine($"StringComparison.Ordinal 옵셥을 이용한 비교 : 와 는 {(result ? "동일하다." : "동일하지 않다.")}"); Console.WriteLine(Environ..

Tistory

[C#/General] Array.Sort와 System.StringComparer를 이용한 배열의 정렬.

public class Example { public static void Main() { string[] lines = new string[] { @"textfile.txt", @"textFile.TXT", @"Text.txt", @"testfile2.txt" }; Console.WriteLine("Non-sorted 상태 :"); foreach (string s in lines) { Console.WriteLine($" {s}"); } Console.WriteLine("\n\rSorted 상태:"); Array.Sort(lines, StringComparer.CurrentCulture); foreach (string s in lines) { Console.WriteLine($" {s}"); } } }

Tistory

[C#/General] Microsoft 제공.. 가장쉬운 async/await 예제.

특정 싸이트에 연결시도하면서 content를 받아오는 도중~~ 특정 Key 이벤트가 들어오면 Cancel 하는 예제. > 즉시 비동기 취소 cancelToken.Cancel() > 일정 기간 이후 비동기 작업 취소 cancelToken.CancelAfter(3500); using System.Diagnostics; class Program { static readonly CancellationTokenSource cancelToken = new CancellationTokenSource(); static readonly HttpClient _httpClient = new HttpClient { MaxResponseContentBufferSize = 1_000_000 }; static readonly IE..

Tistory

[C#/General] 텍스트 제거 (String.Remove)

public class Example { public static void Main() { string source = "I am stronger than Batman."; string toRemove = "stronger "; string result = string.Empty; int i = source.IndexOf(toRemove); if (i >= 0) { result = source.Remove(i, toRemove.Length); } Console.WriteLine(source); Console.WriteLine(result); } }

Tistory

[C#/General] 문자열 내의 특정구문을 개별문자(Char) 처리.

public class Example { public static void Main() { string txt = "I am stronger than Batman."; Console.WriteLine(txt); char[] phraseAsChars = txt.ToCharArray(); int searchIndex = txt.IndexOf("Batman"); if (searchIndex != -1) { phraseAsChars[searchIndex++] = 'C'; phraseAsChars[searchIndex++] = 'a'; phraseAsChars[searchIndex++] = 't'; phraseAsChars[searchIndex++] = 'm'; phraseAsChars[searchIndex++]..

Tistory

[C#/General] String.Replace (텍스트 바꾸기)

public class Example { public static void Main() { string orgin = "CodeKiller is Korean and male."; var replace = orgin.Replace("male", "female"); Console.WriteLine($"The source string is "); Console.WriteLine($"The replace string is "); } }

Tistory

[C#/General] 공백제거 (Trim, TrimStart, TrimEnd)

public class Example { public static void Main() { string source = " I am stronger than Batman. "; var txtTrim = source.Trim(); var txtTrimStart = source.TrimStart(); var txtTrimEnd = source.TrimEnd(); Console.WriteLine($""); Console.WriteLine($""); Console.WriteLine($""); Console.WriteLine($""); } }

Tistory

[C#/General] RegularExpressions(정규식) Match 기능

> Pattern 설명 CodeKiller\. Man "CodeKiller.Man"라는 문자열을 찾습니다. "." 문자는 모든 문자와 일치하는 와일드카드가 아닌 리터럴 마침표로 해석되도록 이스케이프됩니다. (Woman)? "Woman"이라는 0개 또는 1개의 문자열을 찾습니다. using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string input = "The example test lines :" + "'CodeKiller.Man' Test line" + "'CodeKiller.Man' Test line" + "'CodeKiller.ManWoman' Test line"..

Tistory

[C#/General] RegularExpressions : repeated word 찿기 패턴

> 반복적으로 들어간 단어들을 검색하는 패턴 using System; using System.Text.RegularExpressions; public class Example { public static void Main() { // 반복된 단어 검색 패턴을 설명합니다. Regex rx = new Regex(@"\b(?\w+)\s+(\k)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); // Define a test string. string text = "Red red is the The Test test, Codekiller, codekiller"; // 매치 항목 Collection 을 찿습니다. MatchCollection matches = rx.M..

Tistory

[C#/General] RegularExpressions : 특정 Char로 시작하는 word 찿기.

> special char으로 시작하는 word 검색. string pattern = @"\b[cb]\w+"; c 또는 b 로 시작하는 단어를 찿는 패턴입니다. using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"\b[cb]\w+"; string text = "codekiller is red, blue, test, blabla coding."; MatchCollection matches; Regex regex = new Regex(pattern); matches = regex.Matches(text); Console.WriteLine("Pa..

Tistory

[C#/General] 문자열에서 검색하려는 Text의 위치? (IndexOf, LastIndexOf)

문자열에서 검색문자열을 이용하여 위치를 파악하고자 할때 많이 사용되는 기능함수입니다. 앞에서 부터 검색하여 index를 return할때는 IndexOf, 뒤에서 부터 검색하여 index를 return할때는 LastIndexOf string originMessage = "Codekiller is Korean."; // 초기 출력. Console.WriteLine($"\"{originMessage}\""); // first 검색과 last검색 사이의 문자열을 출력합니다. int first = originMessage.IndexOf("Codekiller") + "Codekiller".Length; int last = originMessage.LastIndexOf("Korean"); string str2 = o..

Tistory

[C#/General] RegularExpressions(정규식) Capture 기능

Capture 는 성공한 단일 하위 식 캡처의 결과를 표현합니다. 정규식 패턴은 아래를 참고하세요. (\w+) 하나 이상의 단어 문자를 찾습니다. 이 그룹은 두 번째 캡처링 그룹입니다. [\s.]) 공백 문자 또는 마침표(".")를 찾습니다. ((\w+)[\s.]) 하나 이상의 단어 문자 뒤에 공백 문자 또는 마침표(".")를 찾습니다. 이 그룹은 첫 번째 캡처링 그룹입니다. ((\w+)[\s.])+ 하나 이상의 단어 문자 또는 문자와 공백 문자 또는 마침표(".")를 찾습니다. using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string input = "colors. ..

Tistory

[Oracle] (With절 사용)열을 행으로 변환쿼리!!

with test1 as ( select 'EQ1' as code, '대정수' as item , '2001-08-15' as dtm from dual union select 'EQ1' as code, '소정수' as item , '2001-11-15' as dtm from dual union select 'EQ1' as code, '대정수' as item , '2002-02-15' as dtm from dual union select 'EQ1' as code, '소정수' as item , '2002-04-15' as dtm from dual union select 'EQ1' as code, '고정수' as item , '2001-07-15' as dtm from dual ) SELECT CODE, ite..

Tistory

[Oracle] With 문 사용(Full Join) - 카테시안 조인

with test1 as ( select 'EQ1' as ttt from dual union select 'EQ2' as ttt from dual ), test2 as ( select * from "테스트 할 테이블명" ) select * from test1, test2 where ttt = 'EQ1' 임시테이블 EQ1, EQ2를 만들어서, 테스트할 테이블과 JOIN해서 보여줄때 사용함. =========================================== 응 용 ========================================> with test1 as ( select 'EQ_A' as eq ,'F' as ilsang from dual union select 'EQ_B' as eq, '..

Tistory

[C#/General] 문자열에 Text 포함(Contains, StartsWith, EndsWith)

문자열내에 검색하려는 문자열이 포함되는지 (Contains) 문자열의 앞에서부터 검색하려는 문자열이 포함되는지 (StartsWith) 문자열의 뒤에서부터 검색하려는 문자열이 포함되는지 (EndsWith) string originMessage = "codekiller is Korean."; // Origin Message 출력. Console.WriteLine($"\"{originMessage}\""); // "codekiller" 스트링이 메세지에 포함되는지 확인합니다. bool result = originMessage.Contains("codekiller"); Console.WriteLine($"Contains \"codekiller\"? {result}"); // StringComparison.Cur..

Tistory

[Oracle] 임시테이블 만들어서 INSERT 하기.

1. 테이블 인덱스가 잘못되어 임시테이블을 만들고, 2. 인덱스나 등등.. 잘못된 테이블을 "TRUNCATE ", ''DELETE" 로 삭제후에 3. 밑에와 같이 임시테이블의 값을 제어해서 테이블이 넣음. INSERT INTO FIDMS_EQUI_MST_T (EQUNR, KOSTL, C_KTEXT, EQKTX, EQTYP, TYPTX, STAT, EQART, EARTX, INBDT, ABCKZ, HERST, ARBPL, W_KTEXT, RBNR, RBNRX, TPLNR, PLTXT, ANLNR,TXT50 ) SELECT EQUNR,RTRIM(LTRIM(KOSTL)), RTRIM(LTRIM(C_KTEXT)), EQKTX, EQTYP, TYPTX, STAT, EQART, EARTX, INBDT, ABCKZ,..

Tistory

[Oracle] 엑셀로 테스트용 테이블 만들기.

INSERT 할 테스트 자료가 꽤 많을 경우, 일일히 타이핑하기가 귀찮을때가 많쵸!! 테이블에 INSERT할 테스트 DATA를 엑셀에 한줄을 넣고 셀의 모서리 기능으로 여러셀을 적용하면 INSERT할 내용을 한번에 생성할 수 있습니다. 컬럼1 컬럼2 컬럼3 test1 kim1 hang1 ="INSERT INTO 테이블명 (컬럼1, 컬럼2, 컬럼3) VALUES ('" & A2 & "', '" & B2 & "', '" & C2 & "');" test2 kim2 hang2 test3 kim3 hang3 꽤 많은 양의 테스트 Data를 입력하기 위해서 쿼리문을 작성할때 유용할듯.

Tistory

[Oracle 쿼리] 테이블에 Random 테이트 Data 넣기

[ 테이블에 랜덤 Data값 세팅하기 ] TO_CHAR - 캐릭터 문자로 변환 FLOOR - 최소값의 정수값 DBMS_RANDOM.VALUE - 랜덤값 추출 매우 짧지만, 랜덤데이터를 생성하기에 아주 좋은 예제... SELECT TO_CHAR(FLOOR(DBMS_RANDOM.VALUE(1, 10000))) 보전항목 ,TO_DATE('201001','yyyymm') + FLOOR(DBMS_RANDOM.VALUE(0, 15000)) 계획일자 ,TO_CHAR(FLOOR(DBMS_RANDOM.VALUE(1, 101))) 설비번호 ,CASE WHEN MOD(ROWNUM, 5) = 0 THEN 12 ELSE MOD(ROWNUM, 5) * 12 END 주기 FROM dual CONNECT BY LEVEL

Tistory

[Oracle] 임시테이블 만들어서 INSERT 하기.

1. 테이블 인덱스가 잘못되어 임시테이블을 만들고, 2. 인덱스나 등등.. 잘못된 테이블을 "TRUNCATE ", ''DELETE" 로 삭제후에 3. 밑에와 같이 임시테이블의 값을 제어해서 테이블이 넣음. INSERT INTO FIDMS_EQUI_MST_T (EQUNR, KOSTL, C_KTEXT, EQKTX, EQTYP, TYPTX, STAT, EQART, EARTX, INBDT, ABCKZ, HERST, ARBPL, W_KTEXT, RBNR, RBNRX, TPLNR, PLTXT, ANLNR,TXT50 ) SELECT EQUNR,RTRIM(LTRIM(KOSTL)), RTRIM(LTRIM(C_KTEXT)), EQKTX, EQTYP, TYPTX, STAT, EQART, EARTX, INBDT, ABCKZ,..

Tistory

[Oracle] 조건에 맞는 값만 UPDATE

조건에 맞는 값만 UPDATE 합니다. UPDATE FIDMS_PRDINSP_PLN_T SET EQUNR = ( CASE EQUNR WHEN '1' THEN 'P1-FE510C' WHEN '2' THEN 'P1-FA103-1' WHEN '3' THEN 'P1-EA2202B' WHEN '4' THEN 'P1-EA2202A' WHEN '5' THEN 'P1-EA2201B' ELSE EQUNR END)

Tistory

[Oracle] Create table 테스트 테이블 만들기

:: 사용하고 있는 테이블을 테스트용으로 하나 만들때 사용. CREATE TABLE TMP_PLAN_FF AS SELECT * FROM FIDMS_PRDINSP_PLN_T

Tistory

[Oracle] Select 절에서 Select 사용하기

SELECT 절에서 SELECT 절을 사용해서 쿼리를 간단하게 작성하기. SELECT RP.CLEANING_CD, RP.SUBWORK_CD ,(SELECT CD_NM FROM FIDMS_CODE_T WHERE CD_NO = RP.CLEANING_CD) CLEANING_NM ,(SELECT CD_NM FROM FIDMS_CODE_T WHERE CD_NO = RP.SUBWORK_CD) SUBWORK_NM FROM FIDMS_PRDINSP_PLN_T RP WHERE RP.EQUNR='B1-DA101' AND PSV_ITEM_CD='PSV_T0007' AND RP.PLN_DATE LIKE '2010%'

Tistory

VMware_Install_Cleaner (VM웨어 삭제)

Vmware 5버젼과 7버젼을 번갈아 가며, 설치하니깐!! VisualStudio 에서 디자이너페이지의 컨트롤들이 선택이 안되는 문제가 있더군요. VMware_Install_Cleaner 로 깨끗히 지우시면 됩니다. ^^;

Tistory

[Oracle] 테이블에서 뽑아와서 Insert

테이블에서 자료를 추출해서 테이블에 Data를 Insert 시키는 쿼리. INSERT INTO FIDMS_PRDINSP_PLN_T (PSV_ITEM_CD, PLN_DATE, EQUNR, PSV_TYP, PSV_PER, PLN_TYP, PLN_APP_P ) SELECT TO_CHAR(FLOOR(DBMS_RANDOM.VALUE(1, 1000))) 보전항목코드 ,TO_CHAR(TO_DATE('201001','yyyymm') + FLOOR(DBMS_RANDOM.VALUE(0, 15000)), 'YYYY-MM-DD') 계획일자 ,TO_CHAR(FLOOR(DBMS_RANDOM.VALUE(1, 2000))) 설비번호 ,TO_CHAR(FLOOR(DBMS_RANDOM.VALUE(1, 101))) 보전구분 ,TO_CHAR..

Tistory

[C#/General] 문자열 연결 (String)

> 문자열 리터럴 (literal) string text = "문자열1 " + "문자열2 "; System.Console.WriteLine(text); // 결과 : 문자열1 문자열2 > + 및 += 연산자 string str = "문자열1"; str += " 문자열2"; System.Console.WriteLine(str); // 출력 : 문자열1 문자열2 > 문자열 보간 string str1 = "문자열1"; string str2 = "문자열2"; string str = $"{str1} {str2}"; System.Console.WriteLine(str); // 출력 : 문자열1 문자열2 > String.Format string str = "문자열2"; string s = String.Format("..

Tistory

[HFS] Http File Server

https://www.rejetto.com/hfs/?f=intro HFS ~ HTTP File Server What is it? ... it's file sharing ... it's webserver ... it's open source ... it's free ... it's guaranteed to contain no malware Features Download and upload Virtual file system Highly customizable HTML template Bandwidth control Easy/Expert mode Log Full www.rejetto.com 내 컴퓨터의 특정 Dir 을 공유할 수 있는 프로그램입니다. 특정 대기업 프로젝트에서는 사용할 수 없지만, 중소업체에..

Tistory

[OpenSource] libxml2 (xmlCleanupParser) 사용시 유의점.

http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser parser: the core parser module xmlParserInputPtr resolveEntitySAXFunc (void * ctx, const xmlChar * publicId, const xmlChar * systemId) Callback: The entity loader, to control the loading of external entities, the application can either: - override this resolveEntity() callback in the SA gnome.pages.gitlab.gnome.org xmlCleanupParser 사용시에..

Tistory

[이미지압축] SEO 최적화를 위한 이미지압축 싸이트 5선

> 이미지 압축 Tistory 블로그의 경우 Google Seo의 최적화 프로그램에 걸러지려면 귀찮지만, 이미지를 되도록이면 압축해서 올리는 것을 추천드립니다. https://tinypng.com/ (전 참고로 요놈을 사용합니다. 드래그&드롭으로 사용가능합니다.) TinyPNG – Compress WebP, PNG and JPEG images intelligently Make your website faster and save bandwidth. TinyPNG optimizes your WebP, PNG and JPEG images by 50-80% while preserving full transparency! tinypng.com https://www.iloveimg.com/ko/compress-im..

Tistory

[C#/General] String.Split 사용법

> 기본적인 String.Split 사용. 공백을 구분자로 한 분리. string phrase = "brown red yellow gray black"; string[] colors = phrase.Split(' '); foreach (var color in colors) { System.Console.WriteLine($""); } > 특정 delimiterChars (구분자로 사용되는 Char 집합의 사용) char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; string text = "white\tred :,yellow gray black"; System.Console.WriteLine($"원본 텍스트: '{text}'"); string[] words = ..

Tistory

전자계산서 발급용 인증서 (프리랜서에서 사업자 전환시)

안녕하세요. CodeKiller 입니다. 프리랜서 3.3%에서 사업자 전화시에 신경쓸 사항들이 참 많쵸!! 그중 전자 세금계산서를 홈택스에서 발급(영수/청구)하기 위해서는 사업자 계산서 발급용 인증서가 필요합니다. 물론 범용으로 사용가능한 인증서 입니다. 아래는 저렴하게 발급할 수 있는 싸이트이니 참고하세요 (사업자 내고 계산서 발급이 급하신 분들은 3번으로 해보시면 됩니다. 직접 조달청에 가는 방법으로, 조달청 가실때 꼭 사업자등록증 출력해서 가세요^^.) https://www.signkorea.com/service/g2b.htm 싸인코리아 조달청 1. 우체국 집배원이 고객님을 찾아갑니다. 발급소요시간 : 평균 3~4일(영업일 기준) 범용인증서 할인특가 100,000원 에서 40,000원 으로 할인 문..

Tistory

IT프리랜서 고용보험

> 사업소득으로 매출이 발생하는 프리랜서들도 고용보험이 적용되어 금달(2022.08) 부터는 고용보험료를 노사반반(1.8%->0.9%) 지출이 발생하게 되네요. 중대재해방지법 등, 법이 수시로 바뀌는 2022 시대. 이제는 프리랜서도 근무기간이 6개월이상이면, 실업급여를 받을 수 있는 것은 맞지만, 업체에서 잦은 프로젝트들에 투입되는 개발자들에게 실업급여를 받을 수 있게 신청을 해줄지는 미지수~ 여튼 이런한 고용보험 적용은.... 투입된 직장내에서의 물미스러운 사건/사고를 노무사와 풀어갈 수 있는 루트가 생긴것은 아닐까 생각해봅니다. 아래는 노무불로거 글 링크입니다. (읽어보시면 도움되실것 같네요)

Tistory

[C#/General] 코드에 특성을 추가하는 방법 (Attribute)

> Obsolete 이 클래스는 ObsoleteAttribute로 지칭됩니다. 코드에서는 간략하게 [Obsolete] 이렇게 적으면 되고, 원할 경우 전체 이름 [ObsoleteAttribute]를 사용할 수 있습니다. 클래스를 더 이상 사용되지 않는 것으로 표시할 경우 더 이상 사용되지 않는 이유 및/또는 대싱 사용할 항목에 대한 정보를 제공하는 것이 좋습니다. 이 작업을 위해 Obsolete 특성에 문자열 매개 변수를 전달합니다. [Obsolete("MyClass is obsolete. Use MyClass2 instead.")] public class MyClass { } > 고유한 특성을 만드는 방법 // Attribute로부터 상속받은 클래스를 하나 생성. public class MySpecia..

Tistory

[C#/General] nullable 참조형식 (null-forgiving 연산 => !)

형식 이름에 ?가 추가되지 않은 모든 변수는 null을 허용하지 않는 참조 형식 아래와 같이 ?가 추가되면 null을 허용하는 참조형식을 의미합니다. string? codekiller; 변수 이름 다음에 null-forgiving 연산 ! 를 사용하여 null 상태를 null이 아님으로 강제 적용 codekiller!.Length;

Tistory

[C#/General] 변수 속성구분 (field, property, property get/set/init, property getter/setter)

> field 선언 public class Codekiller { // field 선언. public string CodeKillerName; } > Get/Set 접근자에 의한 선언 public class CodeKiller { // property get/set 선언 public string CodeKillerName { get; set; } // 초기화 public string CodeKillerName { get; set; } = string.Empty; } > 읽기전용 속성을 이용한 선언 public class CodeKiller { public string CodeKillerName { get { return _codeKillerName; } set { _codeKillerName = valu..

Tistory

[C#/General] 문자열 보간 ($) 처리

> 문자열 연결 ($ 보간처리) - 짧은문자열 처리 짧은 문자열 처리시 문자열 보간을 사용하여 연결합니다. string displayAreaName = $"{areaList[n].FirstArea}, {areaList[n].SecondArea}"; > 긴 문자열 연결 텍스트를 사용할 때 문자열을 루프에 추가하려면 StringBuilder 개체를 사용 var phrase = "codekillercodekillercodekillercodekillercodekillercodekillercodekiller"; var manyPhrases = new StringBuilder(); for (var i = 0; i < 10000; i++) { manyPhrases.Append(phrase); } C# 8.0부터는 $..

Tistory

[C#/General] 명령줄 인수를 표시하는 방법

예시> executable.exe a b c 위의 경우 Main에 전달되는 문자열 배열은 "a", "b", "c"와 같습니다. // Length property 는 메인 Arguments의 수를 제공합니다. Console.WriteLine($"parameter count = {args.Length}"); // args 의 정보를 모두 출력합니다. for (int i = 0; i < args.Length; i++) { Console.WriteLine($"Arg[{i}] = [{args[i]}]"); }

Tistory

[C#/General] 문자열 이스케이프 시퀀스

프로그래밍 언어에서 빠지지 않지만 어떤 용어인지 매번 까먹게 되는 이스케이프 시퀀스 정리. 이스케이프 시퀀스 문자이름 유니코드 인코딩 \' 작은따옴표 0x0027 \" 큰따옴표 0x0022 \\ 백슬래시 0x005C \0 Null 0x000 \a 경고 0x0007 \b 백스페이스 0x0008 \f 폼 피드 0x000C \n 줄바꿈 0x000A \r 캐리지리턴 0x000D \t 가로탭 0x0009 \v 새로탭 0x000B \u 유니코드 이스케이프 시퀀스(UTF-16) \uHHHH (범위: 0000-FFFF) \U 유니코드 이스케이프 시퀀스(UTF-32_ \U00HHHHHH (range: 0000000 - 10FFFF) \x 길이가 변하는 경우를 제외하고 “\u”와 유사한 유니코드 이스케이프 시퀀스합니다. ..

Tistory

[C#/General] 상수패턴 (is int) & 논리패턴(is not)

> C# 상수패턴 // 선언패턴(상수패턴)을 이용하여 null 검증 및 변수의 형식을 테스트!!! int? iDeclarePattern = 12; if (iDeclarePattern is int number) { Console.WriteLine($"iDeclarePattern의 값은 {number}"); } else { Console.WriteLine("nullable int iDeclarePattern 변수는 값이 없습니다."); } > C# 논리패턴 string? message = "테스트 스트링"; // 논리패턴으로 null checking if (message is not null) { Console.WriteLine(message); }

Tistory

[C#/General] 코딩규칙 (명명규칙) - 파스칼식 대/소문자 Coding Standard

아래의 C# Coding Style을 참고하세요. GitHub - dotnet/runtime: .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - GitHub - dotnet/runtime: .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. github.com > 파스칼식 Coding Standard (명명규칙) // 첫글자 대문자 (중간에 단어 단위의 앞글자 대문자) public string GetPhy..

Tistory

[C#/General] Main Method 형식

Main Method public static void Main() { } public static int Main() { } public static void Main(string[] args) { } public static int Main(string[] args) { } public static async Task Main() { } public static async Task Main() { } public static async Task Main(string[] args) { } public static async Task Main(string[] args) { } public 은 일반적이지만 필수는 아닙니다. async 및 Task, Task 반환 형식을 추가하면 콘솔 애플리케이션을 시작해야..

Tistory

[C#/General] Generic Class (제네릭 클래스)

> Generic Class // 제네릭 클래스를 선언 public class GenericList { public void Add(T input) { } } // 테스트 클래스 class TestGenericList { private class TestExampleClass { } static void Main() { // int 형의 제네릭 클래스 선언 GenericList list1 = new GenericList(); list1.Add(1); // string 형의 제네릭 클래스 선언 GenericList list2 = new GenericList(); list2.Add(""); // TestExampleClass 형의 제네릭 클래스 선언 GenericList list3 = new GenericL..

Tistory

[C#/General] (익명형식) Anonymous Type은 new { ... }

> 익명형식 (Anonymous Type new {...}) var v = new { Count = 108, Message = "Hello" }; // 무명형식으로 생성된 new 객체를 사용 Console.WriteLine(v.Amount + v.Message); 연산자를 new 사용하여 Anonymous Type 형식을 만듭니다 // linq 내의 익명형식 사용 예 var testQuery = from test in tests select new { test.Color, test.Price }; foreach (var v in testQuery) { Console.WriteLine("Color={0}, Price={1}", v.Color, v.Price); }

Tistory

[C#/General] Main 메서드를 생략

> Main 생략 C# 9를 시작으로 Main 메서드를 생략하고 다음 예제와 같이 Main 메서드 내에 있는 것처럼 C# 문구를 작성할 수 있습니다. 어색한 문법 같지만, Main이 없어도 동작한다는 것에 신기합니다. ^^; using System.Text; StringBuilder builder = new(); builder.AppendLine("Hello"); builder.AppendLine("World!"); Console.WriteLine(builder.ToString());