Blog Content

  • 54.C# - 클래스 복습

    Category C# on 2009. 8. 14. 18:22

    Program.cs using System; using Hyundai; public class 클래스복습 { public static void Main() { Car car = new Car("현대"); car.Length = 2; //2대 car[0] = "에쿠스"; car[1] = "제니시스"; car.Show(); //에쿠스,제니시스 //예3 CarHandler ch = new CarHandler(car.Show); ch(); //예4 car.Go += car.Show; car.OnGo(); } } Car.cs //네임스페이스 추가 namespace Hyundai { using System; //Class public class Car { private string name; //Field publ..

    Read more
  • 41.C# - Class (클래스)

    Category C# on 2009. 8. 11. 19:15

    Class란 변수와 메서드(멤버)및 이벤트를 그룹화 하여 사용하는 것으로 붕어빵을 찍어내는 틀과 불이 클래스 이고 붕어빵 반죽이 변수,메서드 및 이벤트로 보시면 됩니다. 구조체와 클래스의 차이점은 다음과 같습니다. 클래스는 참조형 타입이고 구조체는 데이터 타입입니다. C#에서는 복잡한 기능을 묶어서 사용하고 자 할때는 Class를, 간단한 기능을 묶어서 사용하고자 할 때는 static를 사용합니다. Class 클래스이름 { //클래스 멤버- 필드, 메소드, 변수, 속성, 이벤트 등... } Car.cs using System; //Class public class Car { //Filed public string Color; //Method public void Run() { Console.WriteLi..

    Read more
이전 1 다음