본문 바로가기
728x90
반응형

C#72

IEnumerable vs ICollection vs IList 차이점 IEnumerable class를 foreach loop를 사용하여 반복순회할때 사용한다. IEnumerable interface는 하나의 메소드만 가지고 있다. GetEnumerator() : IEnumerator interface를 반환한다. IEnumerator interface는 2개의 메소드와 하나의 속성을 가지고 있다. MoveNext() : 다음 요소로 이동한다. Reset() : 열거 순서를 처음으로 되돌린다. Current : 현재 요소를 반환한다. IEnumerable을 상속받아 GetEnumerater() 메소드를 구현하면, foreach loop를 사용하는 대신, GetEnumerater()로 IEnumerator를 return 받아 MoveNext(), Current로 대체할 수 .. 2021. 12. 2.
C#] LINQ 쿼리 키워드 let string[] strings = { "A penny saved is a penny earned.", "The early bird catches the worm.", "The pen is mightier than the sword." }; 위 문장을 단어로 나누고, 모음으로 시작하는 단어만 찾아보자. 1. let절 없이 처리하는 경우 //다음의 글을 단어로 쪼개서 모음으로 시작하는 단어를 찾아보자!! string[] strings = { "A penny saved is a penny earned.", "The early bird catches the worm.", "The pen is mightier than the sword." }; //1. 문장을 단어로 쪼갠다. IEnumerable query = .. 2021. 11. 5.
C#] Lambda Lambda Expression 1. Expression Lambda (parameter) => expression class Program { delegate int Calc(int a, int b); // 익명 메소드를 만들기 위한 델리게이트 public static void Main(string[] args) { Calc c = (a, b) => a + b; // 익명 메소드를 람다식으로 구현 Console.WriteLine("{0} + {1} = {2}", 1, 2, c(1, 2)); } } 2. Statement Lambda (parameter) => {code, code, code}; class Program { delegate void DoSomething(); public static vo.. 2021. 11. 5.
C#] Tuple types 간단한 데이터 구조로 여러 데이터 요소를 그룹화하는 간결한 구문 제공 (double, int) t1 = (4.5, 3); Console.WriteLine($"Tuple with elements {t1.Item1} and {t1.Item2}."); // Output: // Tuple with elements 4.5 and 3. (double Sum, int Count) t2 = (4.5, 3); Console.WriteLine($"Sum of {t2.Count} elements is {t2.Sum}."); // Output: // Sum of 3 elements is 4.5. 임의의 많은 요소를 포함하는 튜플 정의 가능 var t = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .. 2021. 10. 13.
C#] EmailTemplate 활용하여 메일 발송하기 1. EmailTemplate.cshtml 2. Model 추가 Model.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace TEST.Models { public class ViewEmail { public string prodName { get; set; } public string name { get; set; } public string telNum { get; set; } public string mail { get; set; } public string address { get; set; } public string title { get; set; } public stri.. 2021. 9. 28.
C#] 메일발송 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Net.Mail; using System.Web; namespace Helper { public class Email { #region SendSimpleMail - Easy Form 메일 전송 /// /// Simple Email 발송 /// /// 보내는사람 메일주소 /// 받는사람 메일주소 /// email 제목 /// email 내용 /// true:HTML사용 / false:HTML미사용 /// public Boolean SendSimpleMail(string fromAddress, string fromName, string toAddress, strin.. 2021. 9. 9.
728x90
반응형