일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- spring
- 합 구하기
- Python
- LCM
- pypy3
- 파이썬
- unity
- 브루투포스
- DP
- Java
- C#강의
- JPA
- 누적합
- c#
- 소수판별
- 백준
- 소수찾기
- python3
- 완전탐색
- 프로그래머스
- mvc
- BFS
- popleft
- 우선순위큐
- deque
- 인프런
- 1일1솔
- 그리디 알고리즘
- 연관관계
- appendleft
- Today
- Total
목록C#강의 (9)
jae_coding
상속 상위 클레스에 있는 변수나 함수를 사용하기 위함 상위 클레스 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Human : MonoBehaviour { // protected는 상속받은 클레스에서만 사용가능하다. protected string humanName; protected int humanage; // virtual 하위 클레스에서 함수를 재정의할 수 있도록 만든다. protected virtual void Info(){ print("나는 인간입니다."); } //추가적인 변수를 넣어주기 위함 (완성은 자식클레스에서 완성시킬 수 있다. 이때는 하위 클레스에서 abstract를 ..
Sturct 구조는 클레스와 동일하지만, 직접 값을 대입시킬 수 없다. 단순히 구조체 역할만 한다. 값을 대입시키기 위해서는 Public을 넣어주거나 parameter를 받아 값을 넣어줄 수 있다. 상속이 불가능하다. class의 구버전이라고 생각하면 될 것 같다. using System.Collections; using System.Collections.Generic; using UnityEngine; public struct School{ public int student_number; public int a; public int b; public int c; public int d; public void Get_number(int Value){ student_number = Value; } // 생..
Namespace: 누군가 만들어 놓은 클레스와 변수, 그리고 함수를 가져다 사용하는 것. 네임스페이스를 사용하는 이유는 대형 프로젝트나 협업을 하는데 함수의 명이나 변수의 이름이 곂칠 경우를 대비하기 위함이다. using을 통하여 어떤 네임스페이스의 어떠한 변수나 함수, 그리고 네임스페이스를 언급해주고 다른 네임스페이스와 곂치지 않게 할 수 있다. using System.Collections; using System.Collections.Generic; using UnityEngine; using Namespace.School; namespace Namespace { namespace School{ public class Person { int student; public void SetFlag(int..
컬렉션 배열의 크기에 대한 단점을 보완해주는 집합체 ArrayList: 연산량이 많아 과부하가 걸릴 수 있다. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Unity_lecture : MonoBehaviour { //배열의 크기가 5로 고정 int[] exp = new int[5] {1, 2, 3, 4, 5}; //컬렉션: 리스트, 큐, 스택, 해시테이블, 딕셔너리, 어레이리스트 //컬렉션을 사용하기 위해서는 using System.Collections;를 head에 넣어주어야함 ArrayList arrayList = new ArrayList(); void Start(){ // Add:..
변수들의 집합체: 배열 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Unity_lecture : MonoBehaviour { // 배열의 선언 int [] exp = {50, 100, 150, 200, 250, 300}; void Start(){ // case 1 print(exp[1]); // 여서 1은 index (배열의 Index는 0부터 시작하므로 100이 출력) print(exp[2]); // 150출력 print(exp[3]); // 200출력 print(exp[4]); // 250출력 print(exp[5]); // 300출력 print(exp[6]); // index의 범..
전역변수, 지역변수, 매개변수 int a = 5; //멤버 변수, 전역변수 void Abc(){ a = 6; int b = 5; // 지역변수 print(b); } void Abc2(){ a = 6; int b = 5; // 지역변수 print(b); } void Abc3(float _parameter){ print(_parameter); // 매개변수 } 전역변수: 전체 코드에 적용할 수 있는 변수 지역변수: 예를들어 하나의 함수안에 선언되어있는 변수(함수 내에서만 사용되는 변수, 전역변수와 이름이 같으면 지역변수가 우선순위가 더 높다) 매개변수: 함수를 사용하기 위해서 매개체로 이용되는 변수 Private, Public의 개념 Private: 다른 class에서 사용이 불가능 Public: 다른 cl..
함수의 기능 예제 함수 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Unity_lecture : MonoBehaviour { int intValue; float floatValue = 10.1f; void FloatToInt(){ intValue = (int)floatValue; } void Start() { FloatToInt(); print(intValue); } // Update is called once per frame void Update() { } } 예제의 코드에서는 함수가 1번밖에 사용되어지지 않았지만, 함수가 여러변 그리고 함수의 내용이 길게 된다면 반복되는 작업을 간..
자료형의 종류 정수 자료형 byte: 정수자료형 0 ~ 256 (1byte) sbyte: 정수자료형 -128 ~ 127 (1byte) short: 정수자료형 -30,000 ~ 30,000 (2byte) integer: 정수자료형 -20억 ~ 20억 (4byte) long: 정수 자형 (8byte) 실수자료형 신뢰성: float < double < decimal 자료형의 선언 // 실수형 float f = 1.000001f; double d = 4.000001; decimal m = 3.000001m; // 문자열 string s = "ABCDEFG"; char c = 'A'; // 0065 유니코드로 변환된다. 자료형의 연산 //자료형이 다른 경우 int a = 100; long b = 100; long..
Unity C # Script의 기본 구성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Unity_lecture : MonoBehaviour { // 최초 1회 실행 void Start() { } // 매 Frame마다 업데이트 void Update() { } } 변수 예를들어 x의 값에 정수 100을 넣고싶다면 타입 변수명 = 정수 + 세미콜론(;)으로 선언을 해주면된다. 흔히 C언어와 변수를 선언하는 것이 동일하다. using System.Collections; using System.Collections.Generic; using UnityEngine; // public class..