전체 글(71)
-
[ C# ] Class 생성자
■ class // 추가 > 클래스 추가 항목 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace aaa { public class Student { private string name; private string Address; public Student(string name, string Address) { this.name = name; this.Address = Address; } public Student(string name):this(name,null) { } public Student():this(null) { } pu..
2023.01.25 -
[ C# ] Window Programing
■ Window Programing Program.cs : 윈폼 생성과 실행 ( 자동 ) Form.cs : 폼 프로그래밍 Form.Designer.cs : 자동생성코드 ( 이벤트처리, 컨트롤 속성 등 ) ■Application class 상속구조 System.Object System.Windows.Threading.DispatcherObject System.Windows.Application public sealed class Application //응용 프로그램을 관리하는 속성 및 정보를 얻기 위한 클래스 ■ UndableVisualStyles() 폼의 스타일 설정 색 , 글꼴 ,테마 등으로 시각적인 요소 설정의 허가 운영체제로부터 가져온다 ■SetCompatibleTextRenderingDefaul..
2023.01.16 -
[ C# ] 인터페이스 ( interface )
■ 인터페이스 ( interface ) 모든 구현은 하위에서 (형식 + 구현 = 상속관계 ) 특징 인터페이스는 구현 없이 형식만 포함 다중 상속 가능 상속으로만 사용하고 생성은 불가 이벤트 , 인덱서 ,메서드 , 속성을 포함 기본 권한은 public이다 형식 관례적으로 대문자 I를 인터페이스명에 붙임 interface I인터페이스명 { ..... } 예 ) interface ITest { void.Print(); } using System; namespace ConsoleApp11 { interface IA { void PrintA(); } interface IB { void PrintB(); } class C : IA, IB { public void PrintA() { Console.WriteLine(..
2023.01.16 -
[ C# ] 상속2
■ Override 상위 메서드를 무시하고 하위에서 재정의 하는 것 대상 : 클래스 메서드 > 속성 ,인덱서, 이벤트 상위 클래스에는 virtual 명시 하위 클래스에는 override 명시 using System; namespace overrideA { class A { public virtual void Print() { Console.WriteLine("A Print"); } } class B : A { public override void Print() { Console.WriteLine("B Print"); } } class Program { static void Main(string[] args) { B Test = new B(); Test.Print(); A Test1 = Test; Test..
2023.01.13 -
[ C# ] 상속
■ 상속 대상 : 클래스 목적 : 클래스의 재사용 > 코드량 줄이기 위해 상속 클래스의 역할 부모 클래스 : 상속을 하는 클래스 자식 클래스 : 상속을 받는 클래스 상속 관계 표시 및 형식 class A // Parent Class { private protected public } Class B : A // Child Class { } // B에서 접근할 수 있는 것? : protected , public // Main과 같은 외부에서 접근 ? : public using System; namespace sangsok { class A { private void PrintPrivate() { Console.WriteLine("private"); } protected void PrintProtected()..
2023.01.13 -
[ C# ] 델리게이트 , 이벤트
■ Delegate 위임하다 (권한, 임무들) 메서드 참조형 복수 또는 단일 메서드를 대신하여 호출하는 역할 > 같은 형식이어야 한다. 메서드만 호출 가능 외부에서 호출 가능 ( private , protected 메서드는 호출 불가 ) - 델리게이트 선언 [ 접근 한정자 ] delegate return형 델리게이트형명 (메서드 매개변수) ; delegate int DelegateType(string Name); ▶ C# 1.0 버전 형식 델리게이트형 델리게이트명 = new 델리게이트형명( 호출할 메서드명 ) DelegateType DelegateMethod = new DelegateType (Function); ▶ C# 2.0 이상 버전 형식 델리게이트형 델리게이트명 = 호출할 메서드형 Delegate..
2023.01.12