C#

학생 관리

s0002 2023. 1. 9. 11:37
using System;

namespace Study07
{
    class Program
    {
        static void Main(string[] args)
        {
            new App();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Text;

namespace Study07
{
    class App
    {

        //생성자
        public App()
        {
            Console.WriteLine("App생성자");

            Students student0 = new Students();
            student0.studentID = 100;
            student0.studentName = "홍길동";
            student0.studentScore = 89;

            Students student1 = new Students();
            student1.studentID = 101;
            student1.studentName = "임꺽정";
            student1.studentScore = 92;

            Students student2 = new Students();
            student2.studentID = 102;
            student2.studentName = "장길산";
            student2.studentScore = 78;

            Students[] students = { student0, student1, student2, null, null };

            foreach(Students student in students)
            {
                if(student!=null)
                 Console.WriteLine("{0},{1},{2}",student.studentID, student.studentName, student.studentScore);
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Text;

namespace Study07
{
    class Students
    {
        public int studentID;
        public string studentName;
        public int studentScore;

        public Students()
        {
            Console.WriteLine("students 배열 요소 생성");
        }
    }
}

'C#' 카테고리의 다른 글

방향키 입력 받아 이동  (0) 2023.01.09
배열에서 찾으려는 숫자의 개수 구하기  (0) 2023.01.09
인벤토리1  (0) 2023.01.08
배열/foreach  (0) 2023.01.08
enum 응용/switch/클래스 간 형 변환  (0) 2023.01.08