설명을 포함하는 5 개의 작업을 사용자가 입력하고 배열을 완료하고 시간당 지불하는 배열이 있습니다. 초보자 용 질문에 사과드립니다.이 언어를 처음 사용했습니다. 어떤 도움을 주시면 감사하겠습니다.C# 배열이 내용을 인쇄하지 않습니다.
private static void EnterJobs()
{
//string inputString;
for (int i = 0; i < jobArray.Length; i++)
{
Job job = new Job();
Console.WriteLine("Job " + i);
Console.WriteLine("Enter a job description.");
job.Description = Console.ReadLine();
Console.WriteLine("Enter the amount of hours required to complete the job.");
job.hoursToComplete = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the hourly rate for the job.");
job.hourlyRate = Convert.ToInt32(Console.ReadLine());
jobArray[i] = job;
}
나는 그냥 메모장이를 두었다
for (int i = 0; i < jobArray.Length; i++)
{
Console.WriteLine(jobArray[i]);
}
어떻게 닷넷 당신이'Job' 유형이 콘솔에 같이 원하는 것을 알아야 할 것? 그것을 알려주는 ToString() 메서드가 필요합니다. –
각 작업이 다른 속성 또는 필드 (또는 둘 다)를 가질 때 단일 변수와 같은 클래스를 처리합니다. 그 각각을 처리해야합니다. –