Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 백준 1003번
- 백준 1978번
- 10진수 2진수
- c 백준 4344번
- 백준 알고리즘
- 프로그래머스
- 십진수 이진수
- 8진수
- 백준 2869번
- 백준 2775번
- 알고리즘
- programers
- 백준
- 16진수
- C
- 비트시프트
- 배열 소수
- 백준 10817번
- 백준 4344번
- 백준 2839번
- 백준 달팽이
- 백준 10989
- 10989 C
- 백준 세수
- 공부
- 백준 2751번
- 백준 1712번
- 2751번 C
- 백준 손익분기점
- 백준 1026번
Archives
- Today
- Total
IT Diary
static이란 본문
Static
Static method는 static member만 엑세스 할 수 있습니다.
Static method 반대 instance method
- 정적 키워드로 선언한 메서드는 객체 인스턴스를 생성(new 인스턴스 이름)하면 힙 memory 공간 안에 객체가 생성됨
- 값을 공유하기 위한 용도로 사용하기 위함
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace Day0705
{
class Program
{
static void Main()
{
StatTest.StatPrn(); // 정적 메서드는 따로 객체 생성을 안해도 됨
StatTest nonTest = new StatTest();
nonTest.Prn();
}
}
class StatTest
{
public static void StatPrn()
{
// Console.WriteLine is a static method.Console.Out is a static
// object that can get passed as a parameter to any method that takes a TextWriter,
// and that method could call the non-static member method WriteLine.
Console.Out.WriteLine("Static에서 작동하는 Method");
}
public void Prn()
{
Console.Out.WriteLine("non-Static에서 작동하는 Method");
}
}
}
'language > C#' 카테고리의 다른 글
IEnumerable vs ICollection vs IList vs IQueryable in C# (0) | 2020.08.11 |
---|---|
C# 0729 질문 (0) | 2020.07.29 |
바인딩 (0) | 2020.06.25 |
TREAD 개념 (0) | 2020.06.21 |
5장 그래픽 (0) | 2020.05.05 |
Comments