기본적으로 asp.net MVC는 주소를 통해 어떤 Controller의 Action(Method)를 판단 할 수있으며 추가적으로 Id나 기타 Parameter를 던져줄수도 있다. 또한 기본값(default)은 HomeController의 Index메서드 이며 해당부분은 App_Start폴더의 RouteConfig에서 수정 가능하다. // https://localhost:44385 // URL뒤에 아무것도 없을시에 HomeController의 Index Action를 따라간다. // https://localhost:44385/Member/Login // MemberController의 Login Action #1. MVC 웹 어플리케이션 생성을 위해 아래와 같은 형식의 프로젝트를 생성한다. #2. 프로젝..
upcasting이란 자식클래스의 형식에서 부모클래스의 형식으로 casting 바뀌는것을 말한다. 즉 하나의 매개변수형 (상위)로 상속 받은 자식클래스의 매개변수형을 받아 오는것이다. using System; namespace casting_1 { public class Sample { } public class Sample1 : Sample { } public class Sample2 : Sample { } public class Sample3 : Sample { } public class SamplePrint { /* 자식클래스가 추가될때마다 매서드를 오버로딩 시켜주어야함 public void Print(Sample1 sample) { Console.WriteLine("Print " + sample)..
winForm을 이용해서 ms-sql과 데이터베이스를 연결하는 기본적인 내용 데이터베이스에 연결이후에는 여러가지 쿼리를 사용해서 데이터를 가져올수있다. using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Windows.Forms; namespace mssql_connect { public partial class Form1 : Form { private string _dbConnect; public Form1() { InitializeComponent(); } private void btn_connect_Click(object sender, EventArgs e) { string dbHost = ..
docs.microsoft.com/ko-kr/dotnet/api/system.guid.newguid?view=net-5.0 Guid.NewGuid 메서드 (System) Guid 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Guid structure. docs.microsoft.com using System; namespace guid { class Program { static void Main(string[] args) { for (var i = 1; i < 15; i++) { var uid = Guid.NewGuid().ToString(); Console.WriteLine($"#{i}. {uid}"); } } } }
docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/classes-and-structs/abstract-and-sealed-classes-and-class-members 추상 및 봉인 클래스와 클래스 멤버 - C# 프로그래밍 가이드 C#의 추상 키워드를 사용하여 불완전한 클래스와 클래스 멤버를 만듭니다. Sealed 키워드는 이전 가상 클래스 또는 클래스 멤버의 상속을 방지합니다. docs.microsoft.com abstract는 추상 클래스로써 자식클래스에서 override 할 때 사용되며 다음과 같은 특징이 있다. 1. abstract 매서드 선언시에는 body ({})부분이 없다. 2. abstract 매서드 선언시에는 클래스 앞에 abstract..
docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/override override 한정자 - C# 참조 override(C# 참조)override (C# reference) 이 문서의 내용 --> override 한정자는 상속된 메서드, 속성, 인덱서 또는 이벤트의 추상 또는 가상 구현을 확장하거나 수정하는 데 필요합니다.The override modifier is re docs.microsoft.com override는 자식클래스에서 부모클래스에서 받은 메서드를 재정의해서 사용할때 사용한다. override를 해주는 부모클래스에서는 각각 virtual과 abstract 이 두가지로 나누어지는데 기본적으로 부모클래스의 역할이 있고 자식..
docs.microsoft.com/en-us/dotnet/api/system.timespan?view=net-5.0 TimeSpan Struct (System) Represents a time interval. docs.microsoft.com DateTime에 이어 TimeSpan이라는 클래스도 있다. 마찬가지로 static으로도 쓰일수 있고, 인스턴스화 이후에 사용해도 된다. using System; namespace timespan { class Program { static void Main(string[] args) { // Create var timeSpan = new TimeSpan(1, 2, 3); var timeSpan1 = new TimeSpan(1, 0, 0); var timeSpan..
docs.microsoft.com/en-us/dotnet/api/system.datetime?view=net-5.0 DateTime Struct (System) Represents an instant in time, typically expressed as a date and time of day. docs.microsoft.com C#에서도 다른언어와 마찬가지로 날짜와 시간을 다룰수있는 클래스가 있다. DateTime 자체에서 static으로 불러와서 사용해도되고 new 키워드를 통해서 인스턴스화 해도 된다. using System; namespace datetime { class Program { static void Main(string[] args) { // Static var staticNow ..
docs.microsoft.com/en-us/dotnet/api/system.io.path?view=net-5.0 Path Class (System.IO) Performs operations on String instances that contain file or directory path information. These operations are performed in a cross-platform manner. docs.microsoft.com 마지막으로 Path System.IO에 있는 내용들을 활용하면 파일관련사항들은 처리 할 수 있다. using System.IO; namespace __Path { class Program { static void Main(string[] args) { var..
docs.microsoft.com/en-us/dotnet/api/system.io.directory?view=net-5.0 Directory Class (System.IO) Exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited. docs.microsoft.com 일전의 File과 FileInfo와의 차이처럼 각각 static이냐 인스턴스화 시키냐의 차이정도 있다. 단순하게 쓸 경우는 Directory 여러가지 작업을 할 경우는 DirectoryInfo using System; using System.IO; namespace ..
docs.microsoft.com/ko-kr/dotnet/api/system.io.fileinfo?view=net-5.0 FileInfo Class (System.IO) Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects. This class cannot be inherited. docs.microsoft.com File과 FileInfo는 각각 System.IO에서 지원해준다. 두가지의 가장 큰 차이점은 File은 static 매서드 이고 FileInfo는 instance 매서드이..
Generic Type은 특정 클래스나 함수에서 여러가지 데이터타입을 인자값으로 받거나 리턴해줄때 사용한다. 기본적인 사용방법은 다음과 같다. // T는 다른 임의의 값을 넣어도 상관없다. public static class GenericSample { public static void Print(T _Value) { Console.WriteLine(_Value); } } public class GenericSample2 { } 위와 같이 선언해준다음에 위치에 원하는 데이터 타입을 넣어준다. 아래와 같은 상황에서 쓰이면 유용하다. public static class Sample { public static void Print(int _Value) { Console.WriteLine(_Value); } p..