본문 바로가기
Programming

나열형(enum)과 구조체(struct) 선언.

by Mizix 2010. 7. 20.
반응형

나열 형식 선언하기

enum Season { Spring, Summer, Fall, Winter }

 

나열형 변수 선언하기

Season currentSeason;

 

나열형 변수에 값 지정하기

currentSeason = Spring; //오류

currentSeason = Season.Spring //올바름

 

구조체 선언하기

struct Time

{

   public Time(int hh, int mm, int cc)

   { … }

   …

   private int hours, minutes, seconds;

}

 

구조체 변수 선언하기

Time now;

 

구조체 변수에 값 초기화하기

Time lunch = new Time(12, 30, 0);

반응형

'Programming' 카테고리의 다른 글

각종 DB JDBC 연결  (0) 2010.08.17
인덱서  (0) 2010.08.06
JDK 1.6 + mssql 2005 연동하기.  (0) 2010.06.25
게시판 리스트 처리.  (0) 2010.06.10