コード例 #1
0
 public void printall()
 {
     if (array == null)
     {
         return;
     }
     Console.WriteLine("저장개수 : {0}개", array.Size);
     for (int i = 0; i < array.Size; i++)
     {
         member mem = (member)array.getdata(i);
         Console.WriteLine(mem);
     }
 }
コード例 #2
0
 private int nametoidx(string name)
 {
     for (int i = 0; i < array.Size; i++)
     {
         member mem = (member)array[i];
         //if (mem.Name.Equals(name) == true)
         if (mem == name)
         {
             return(i);
         }
     }
     throw new Exception("없음");
 }
コード例 #3
0
        public void select()
        {
            try
            {
                string name = wblib.inputstring("검색 이름");

                member mem = (member)array[nametoidx(name)];
                Console.WriteLine(mem);
            }
            catch (Exception ex)
            {
                Console.WriteLine("검색 오류");
                Console.WriteLine(">> " + ex.Message);
            }
        }
コード例 #4
0
        public static void filesersave(object[] arr, int size)
        {
            Stream          ws         = new FileStream("mlist.txt", FileMode.Create);
            BinaryFormatter serializer = new BinaryFormatter();

            int max = arr.Length;

            serializer.Serialize(ws, max);
            serializer.Serialize(ws, size);

            for (int i = 0; i < size; i++)
            {
                member mem = (member)arr[i];
                serializer.Serialize(ws, mem);
            }
            ws.Close();
        }
コード例 #5
0
        public static member[] fileload()
        {
            Stream inStream =
                new FileStream("a.txt", FileMode.Open);

            //갯수
            byte[] sizebytes = new byte[2];
            sizebytes[0] = (byte)inStream.ReadByte();
            sizebytes[1] = (byte)inStream.ReadByte();
            string str = Encoding.Default.GetString(sizebytes);

            Console.WriteLine(str);

            //본 데이터
            byte[] rbytes = new byte[int.Parse(str)];
            int    i      = 0;

            while (inStream.Position < inStream.Length)
            {
                rbytes[i++] = (byte)inStream.ReadByte();
            }

            string str1 = Encoding.UTF8.GetString(rbytes);

            Console.WriteLine(str1);
            inStream.Close();

            //배열 담기
            string[] temp    = str1.Split('@');
            member[] memlist = new member[temp.Length - 1];
            int      j       = 0;

            for (int i1 = 0; i1 < temp.Length - 1; i1++)
            {
                string[] temp1 = temp[i1].Split('#');
                //객체 분리
                member mem = new member(
                    temp1[0],
                    temp1[1],
                    (enumdept)2,//int.Parse(temp1[3]),
                    int.Parse(temp1[2]));
                memlist[j++] = mem;
            }
            return(memlist);
        }
コード例 #6
0
        public void update()
        {
            try
            {
                string name = wblib.inputstring("수정 이름");
                member mem  = (member)array[nametoidx(name)];

                mem.Phone = wblib.inputstring("전화번호");
                mem.Grad  = wblib.inputnumber("학년");
                mem.Dept  = (enumdept)wblib.inputnumber("학과 [1]컴 [2]IT [3]게임 [4]기타");
                Console.WriteLine("수정 완료");
            }
            catch (Exception ex)
            {
                Console.WriteLine("수정 오류");
                Console.WriteLine(">> " + ex.Message);
            }
        }
コード例 #7
0
        public static member[] fileserload(out int max)
        {
            Stream          rs           = new FileStream("mlist.txt", FileMode.Open);
            BinaryFormatter deserializer = new BinaryFormatter();

            max = (int)deserializer.Deserialize(rs);
            int size = (int)deserializer.Deserialize(rs);

            Console.WriteLine("불러온 최대저장개수 : {0}개", max);
            Console.WriteLine("불러온 개수 : {0}개", size);

            member[] memlist = new member[size];
            for (int i = 0; i < size; i++)
            {
                memlist[i] = (member)deserializer.Deserialize(rs);
            }
            rs.Close();

            return(memlist);
        }
コード例 #8
0
        public void fileload()
        {
            try {
                //member[] arr=wbfile.fileload();
                int      max;
                member[] arr = wbfile.fileserload(out max);
                array = new wbarray(max);

                for (int i = 0; i < arr.Length; i++)
                {
                    member mem = arr[i];
                    array.insert(mem);
                }
            }
            catch (FileNotFoundException)
            {
                //파일이 없으니깐 배열객체를 생성하겠다.
                int size = wblib.inputnumber("배열의 크기");
                array = new wbarray(size);
            }
        }