본문 바로가기

이것이 c#이다14

[C#] 오버라이딩 오버 라이딩 - 클래스의 상속 관계에서 사용하는 개념으로 다른 의미로 재정의 하는 것을 의미한다. 메서드를 오버 라이딩하기 위해서는 조건이 필요한데, 오버 라이딩을 할 메서드가 virtual 키워드로 한정되어 있어야 한다는 것이다. 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 using System; using static System.Console; using System.Collections; namespace AS { class ArmorSuite { public virtual voi.. 2019. 5. 18.
[C#] 상속 상속(Inheritance) - 클래스는 다른 클래스로부터 유산을 물려받을 수 있다. 클래스에게 있는 유산이란 필드나 메서드, 프로퍼티 같은 멤버들을 말한다. 객체 지향 프로그래밍에서는 물려받는 클래스(파생 클래스)가 유산을 물려줄 클래스를 지정한다. 형식 class 기반 클래스 { // 멤버 선언 } class 파생 클래스 : 기반 클래스 { // 아무 멤버를 선언하지 않아도 기반 클래스의 모든 것을 물려받아 갖게 된다. // private로 선언된 멤버는 제외! } 또한 파생 클래스는 기반 클래스로부터 물려받은 멤버들 외에 고유의 메서드와 멤버를 추가해서 사용하게 된다. 이것은 파생 클래스가 기반 클래스 위에 새로운 멤버를 "얹어" 만든 것이기 때문이다. 파생 클래스의 생성 과정을 통해서도 확일 할 .. 2019. 5. 18.
[C#] foreach문 foreach - 주로 배열이나 컬렉션에 사용되는 반복문이다. 컬렉션의 각 요소를 하나씩 꺼내와서 foreach 루프 내의 블록을 실행할 때 사용된다. 편리하게도 배열 (또는 컬렉션)의 끝에 도달하면 자동으로 반복이 종료된다. 예제 foreach(데이터 형식 변수명 in 배열_또는_컬렉션) 코드 또는 코드 블록 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 using System; using static System.Console; namespace Foreach { class MainApp { static void Main(string[] args) { int[] arry = new int[] { 1, 2, 3, 4, 5, 6 }; foreach (var arr in arry) .. 2019. 5. 18.
이것이 C# 10장 연습문제 풀이 1. string 형식을 int 로 변환할수 없습니다. 2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 using System; using static System.Console; namespace Practice2 { class MainApp { public static void Main() { int[,] A = new int[2, 2] { { 3, 2 }, { 1, 4 } }; int[,] B = new int[2, 2] { { 9, 2 }, { 1, 7 } }; int[,] Result = new int[2, 2] { {(A[0 , 0] * B[0 , 0]) + (A[0 , 1] * B[1 , 0]) , (A[ 0 , 0] * .. 2019. 5. 13.
이것이 C# 9장 연습문제 풀이 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 using System; using static System.Console; namespace Practice2 { class NameCard { public int age { get; set; } public string name { get; set; } } class MainApp { public static void Main() { NameCard nameCard = new NameCard() { name = "상현", age = 24 }; WriteLine("나이 : {0}", nameCard.age); WriteLine("이름 : {0}", nameCard.name); } } } http://colorsc.. 2019. 5. 13.
이것이 C# 5장 연습문제 풀이 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 using System; using static System.Console; namespace Practice2 { class MainApp { public static void Main() { for (int i = 0; i Colored by Color Scripter 3. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 using System; using static System.Console; namespace Practice2 { class MainApp { public static void Main() { int i = 0; while(i Colore.. 2019. 5. 8.