【发布时间】:2018-02-26 20:59:51
【问题描述】:
我的任务是在 C# 中创建一个记录保存控制台应用程序,用于添加、查看和删除记录。我需要使用数组、列表或字典(或某种组合)。
我尝试过使用数组和列表,但到目前为止,字典被证明是最成功的(我知道如何在这个程序中最好地使用它们)。照片中是我到目前为止的代码,但是当我提示用户输入信息时出现错误。我尝试了一些不同的修复方法,但都没有奏效。
class Patient
{
public static string PatientDict;
public Console.WriteLine("Enter the patient's name: ");
string PatientName = Console.ReadLine();
public Console.WriteLine("Enter the patient's date of birth: ");
string PatientDOB = Console.ReadLine();
public Console.WriteLine("Enter the patient's age: ");
string PatientAge = Console.ReadLine();
public Console.WriteLine("Enter the patient's ailment(s): ");
string PatientAilments = Console.ReadLine();
public Console.WriteLine("Enter the patient's medication(s): ");
string PatientMeds = Console.ReadLine();
string DOB;
string Age;
string Ailments;
string Meds;
}
【问题讨论】:
-
public Console.WriteLine("Enter the patient's name: ");?我认为您需要继续阅读 c# 教程,这根本无效 -
创建一个方法来放置代码,你把字段和语句混淆了。
-
根据我在课堂上的记忆,Console.WriteLine();我的教授用的是什么,我在网上找到了什么? (我添加了 public 作为随机修复尝试)
-
您的教授可能确实使用了
Console.WriteLine();只有正确。不要试图通过随机更改来修复代码;编程太复杂了,无法通过这种方式学习。反而; read tutorials 和[文档(msdn.microsoft.com/en-us/library/system.console(v=vs.110).aspx)。
标签: c# error-handling console syntax-error console-application