c# 49

내가 볼 c# 메모(계속 업데이트 예정)

본 작성글에는 부정확하거나 부실한 정보가 있을 수 있음을 미리 알려드립니다 별로 메모 안해도 될 것 같은 키워드 명명된 인수 선택적 인수(명명된 인수랑 같이 써야할 듯) goto(이거 쓰면 디버깅하기 힘들어져서 비추천한다고 함) 소멸자 인덱서(Indexer : 프로퍼티 접근을 프로퍼티 이름을 사용하는 것이 아닌 인덱스를 이용해 접근 하는 방법이다. 굳이 이걸 왜 쓰는지는 모르겠다) 리플렉션(객체의 형식정보를 알 수 있는 기능이라는데, 굳이 쓸 필요는 없을 것 같다) 애트리뷰트(유니티 공부하면서 SerializeField 같은 애트리뷰트는 자주 써봤다. 궁금할 때 찾아봐도 될 듯) 다이나믹 형식(dynamic : 써야할 이유를 모르겠다, 굳이 알 필요도 없을 것 같다) 나중에 메모할 키워드 : is ref..

c# 2024.02.06

초보자들을 위한 .Net 8.0 다운 후 적용하는 법

백준 문제를 풀다가 c#만의 새로운 문법을 써보고 싶어서 .Net에 대해 찾아보다 글을 쓰게 되었다 Visual Studio 버전 .Net 8.0버전을 쓰기 위해서는 Visual Studio 2022 (v17.8) 이상 버전의 비주얼 스튜디오가 필요하다 미리 다운받거나 업데이트 해주도록 하자 .NET 다운로드 https://dotnet.microsoft.com/ko-kr/download .NET 다운로드(Linux, macOS 및 Windows) Linux, macOS 및 Windows에서 .NET 앱을 빌드하고 실행하기 위한 무료 다운로드. .NET Framework, .NET 및 ASP.NET용 런타임, SDK 및 개발자 팩. dotnet.microsoft.com 이 사이트에서 닷넷 8.0버전을 다운..

c# 2024.02.04

백준 14215번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan; //입력값과 그 입력값을 숫자로 변환해서 저장할 배열 string[] input = new string[3]; int[] num = new int[3]; //입력값 받아옴 input = Console.ReadLine().Split(); //input배열에 있는 입력값을 int형으로 변환하여 num배열에 저장 for (int i = 0; i < 3; i++) { num[i] = int.Parse(inpu..

백준 2024.02.03

백준 5073번 c#

using System; using System.Text; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan; //결과값 저장할 변수 StringBuilder sb = new StringBuilder(); //입력값과 그 입력값을 숫자로 변환해서 저장할 배열 string[] input = new string[3]; int[] num = new int[3]; //무한반복 while (true) { //입력값 받아옴 input = Console.ReadLine().Split(); ..

백준 2024.02.03

백준 10101번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan; //각 받아올 배열 int[] angle = new int[3]; //각의 총합 구할 변수 int num = 0; //총 3번 반복 for (int i = 0; i < angle.Length; i++) { //angle배열에 각을 입력해서 대입해줌 angle[i] = int.Parse(Console.ReadLine()); //num 변수에 각의 총합을 더함 num += angle[i]; } //삼각형의..

백준 2024.02.02

백준 9063번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan;; //구슬 갯수 받아옴 int bead = int.Parse(Console.ReadLine()); //구슬 좌표 임시로 받아올 변수 string[] coordinate = new string[2]; //각 구슬 좌표의 x,y 값들을 저장할 변수 int[] x = new int[bead]; int[] y = new int[bead]; //발견한 구슬 개수만큼 반복 for (int i = 0; i < be..

백준 2024.02.02

백준 15894번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan;; //1에서 100억의 정수가 들어간다는 사실에 주의 //int.Parse가 아닌 long.Parse를 써준다 Console.WriteLine(long.Parse(Console.ReadLine()) * 4); } } } 공식자체는 쉬워서 당연히 한번에 맞출거라고 생각했지만 함정이 있었다 함정은 바로 입력값이 100억까지란 것이었고 int의 범위는 -2,147,483,648 ~ 2,147,483,647이..

백준 2024.02.02

백준 3009번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan;; //입력값 넣을 변수 string[] input = new string[2]; //x,y 축을 구별하여 넣을 변수 int[] x = new int[3]; int[] y = new int[3]; //결과값 넣을 변수 string result = ""; //3번반복 for (int i = 0; i < 3; i++) { //입력값을 받아서 x와 y를 각각 배열에 저장함 input = Console.Read..

백준 2024.02.01

백준 1085번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan; //입력값 받을 변수 string[] input = Console.ReadLine().Split(); //본인 위치에서 각 변까지의 거리 구해서 넣을 변수 //길이 4 int[] distance = new int[4]; //4번 반복함 for (int i = 0; i < 4; i++) { //만약 i가 1 이하라면 실행 if (i

백준 2024.02.01

백준 27323번 c#

using System; namespace Baekjoon { internal class Program { static void Main(string[] args) { //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음) Console.BackgroundColor = ConsoleColor.DarkCyan; //길이 2인 배열 생성 string[] input = new string[2]; //각 배열에 입력값 받아옴 input[0] = Console.ReadLine(); input[1] = Console.ReadLine(); //각 입력값 int로 형변환 후 곱하기 값 출력 Console.WriteLine(int.Parse(input[0]) * int.Parse(input[1])); } } }

백준 2024.02.01