using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
int index = 0;
int input;
MyInfo[] myinfoarray = new MyInfo[10]; //클래스배열 선언
public class MyInfo // 클래스 생성
{
public string Arrusername;
public int Arruserphone;
public MyInfo() //초기화
{
Arrusername = string.Empty;
Arruserphone = -1;
}
}
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
myinfoarray[i] = new MyInfo();
}
Main(); //메인 호출
}
public void Main()
{
Console.Clear();
MainView();
input = int.Parse(Console.ReadLine());
Console.WriteLine("입력값 : " + input);
if (input == 0)
{
// 정보입력 호출
Console.Clear();
Infoinput();
}else
{
//전체출력 호출
Console.Clear();
Infoprint();
}
}
public void Infoinput() //정보입력
{
Console.WriteLine("--정보입력화면--");
Console.Write("이름 입력 : ");
myinfoarray[index].Arrusername = Console.ReadLine();
Console.Write("번호 입력 : ");
myinfoarray[index].Arruserphone = int.Parse(Console.ReadLine());
index = index + 1;
Console.ReadLine();
Main();
}
public void Infoprint() //전체출력
{
for (int i = 0; i < index; i++)
{
Console.WriteLine("-----------{0}------------", i);
Console.WriteLine("이름 : " + myinfoarray[i].Arrusername);
Console.WriteLine("번호 : " + myinfoarray[i].Arruserphone);
Console.WriteLine("------------------------");
}
Console.ReadLine();
Main();
}
public void MainView() //메인화면
{
Console.WriteLine("-----------------------");
Console.WriteLine("0. 정보 입력");
Console.WriteLine("1. 전체 출력");
Console.WriteLine("---------------------");
Console.WriteLine("메뉴를 선택하세요");
}
}
}
결과 화면
'C#' 카테고리의 다른 글
📚 [C#] winform 콘솔 출력 (0) | 2023.01.11 |
---|
댓글