목록C# (132)
S_pot
namespace _210614_002 { public delegate void SMART(); public delegate int SMART2(int iNum); class Program { static void Main(string[] args) { SMART A; A = () => // delegate () 와 같다. { Console.WriteLine("임시로 만든 메소드"); }; A(); } static void Main4(string[] args) { SMART2 A; A = Test2; int iNum = A(100); Console.WriteLine(iNum); A = (int iNumber) => // 람다식 { Console.WriteLine("익명 혹은 무명 메서드테스트"); ret..
namespace _210614_002 { public delegate void SMART(); public delegate int SMART2(int iNum); class Program { static void Main(string[] args) { SMART A; A = () => // delegate () 와 같다. { Console.WriteLine("임시로 만든 메소드"); }; A(); } static void Main4(string[] args) { SMART2 A; A = Test2; int iNum = A(100); Console.WriteLine(iNum); A = (int iNumber) => // 람다식 { Console.WriteLine("익명 혹은 무명 메서드테스트"); ret..

class Program { delegate void SMART(); static void Test1() { Console.WriteLine("Test1"); } static void Test2() { Console.WriteLine("Test2"); } static void Test3() { Console.WriteLine("Test3"); } // MessageMap 기법: struct MessageMap { public string Name { get; set; } // 속성값 설정 public SMART Handle { get; set; } } static void Main(string[] args) { MessageMap[] Map = new MessageMap[]{ new MessageMap{..

class Program { // delegate SMART type을 생성 delegate void SMART(); static void Main(string[] args) { Test1(); Test2(); Test3(); SMART A; A = Test1; A(); // Test1();과 같은 내용이 호출된다. 변수로 Test1을 가르킬 수 있다. A = Test2; A(); A = Test3; A(); } static void Test1() { Console.WriteLine("Test1"); } static void Test2() { Console.WriteLine("Test2"); } static void Test3() { Console.WriteLine("Test3"); } } class P..

interface Phone { void Call(); void Recv(); } // 자동으로 코드생성 가능 class Sami : Phone // interface Phone을 상속받으면 call()과 Recv()를 모두 사용하지 않으면 실행되지 않는다. // 실수로 기능을 빼먹는 것을 방지한다.(인터페이스의 장점) { public void Call() { Console.WriteLine("나 사미전화긴데 전화 검"); } public void Recv() { Console.WriteLine("나 사미전화긴데 전화 받음"); } } class Hong : Phone // 자동으로 코드생성 가능 { public void Call() { Console.WriteLine("나 홍전화긴데 전화 검"); } ..
class Program { class Parent { } class Child : Parent, IDisposable, IComparable // 한개의 클래스와 두 개의 인터페이스를 상속받습니다. { public int CompareTo(object obj) // IComparable 인터페이스 구현 { throw new NotImplementedException(); } public void Dispose() // IDispose 인터페이스 구현 { throw new NotImplementedException(); } } static void Main(string[] args) { } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; abstract class Smart { int iNum1; int iNum2 { set { } get { return 100; } } int iNum3 { get; set; } void test1() { } public abstract void test2(); } interface IBasic2 { // int iNum; // 인터페이스는 안에 인스턴스 변수를 선언할 수 없다. // int iNum2{set{ } get{ }} // 불가: 세부설정 사용안됨 // void test2() { } // ..
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; //interface namespace Hong { interface ISmart { } } namespace Kim { interface ISmart { } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Hong; using Kim; // Program.cs namespace Busan { class Program { stat..
namespace _210604_004 { // iComparable 인터페이스 // 정렬하기 위해서는 IComparable을 상속받아야 하고 // CompareTo메서드를 생성해주어야 한다. class Program { class Product : IComparable // 자동으로 메서드 생성가능 { public string Name { get; set; } public int Price { get; set; } // Name으로 비교정렬 public int CompareTo(object tttt) // 비교메서드를 입력해주어야 한다. { return this.Name.CompareTo(((Product)tttt).Name); // 이름순으로 정렬 } // Price로 비교정렬 /* public in..