나는 Windows 콘솔 응용 프로그램에서 간단한 전화 번호부 프로그램을 만들려고 노력하고 있습니다. SortedDictionary는 Key가 name이고 Value가 숫자이고, List가 주소이고 StringDictionary가 email-ids입니다. 이 클래스들을 모두 Directory라는 클래스에 넣은 다음 Main의 인스턴스를 통해 호출했습니다. 디렉토리를 열거하는 데 문제가 있습니다. 같은 줄에 사람의 네 항목을 모두 인쇄하고 싶습니다. 아무도 내가 어떻게해야하는지 말해 줄 수 없다. 이것은 내가 해 봐야 내 logic..Sorry에서 많은 실수가 불편 있다는 것을 잘 확신했다 방법입니다 -전화 번호부 예
public class Directry
{
List <string> Email_id= new List <string>();
SortedDictionary<string, int> Dict = new SortedDictionary<string, int>();
StringCollection Adress=new StringCollection();
public Directry(SortedDictionary<string, int> dict, StringCollection adress, List<string> email)
{
this.Dict = dict;
this.Email_id = email;
this.Adress = adress;
}
}
class Another
{
static void Main(string[] args)
{
SortedDictionary<string, int> dict = new SortedDictionary<string, int>();
List<string> email = new List<string>();
StringCollection adres = new StringCollection();
Directry dir = new Directry(dict, adres,email);
string key, adress, Email;
int numbr;
start_again:
for (int i = 0; i <2; i++)
{
Console.WriteLine("enter name to be added in the directory");
key = Console.ReadLine();
Console.WriteLine("enter number to be added in the directory");
numbr = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter address to be added in the directory");
adress = Console.ReadLine();
Console.WriteLine("enter your email-id to be added in the directory");
Email = Console.ReadLine();
dict.Add(key, numbr);
email.Add(Email);
adres.Add(adress);
}
Console.WriteLine("do you wish to continue-y/n?");
char c = Convert.ToChar(Console.ReadLine());
if (c == 'y')
{
Console.WriteLine("you said yes");
goto start_again;
}
else
{
Console.WriteLine("no more entries can be added");
Console.WriteLine("Name Number adress email");
foreach (object ot in dir)
{
Console.WriteLine(ot);
}
}
Console.ReadLine();
}
}
감사합니다. 그것의 모양으로
같은이 코드를 컴파일 하는가 수 있을까요? – nik0lias
그것은 foreach 성명에서 나에게 문제를 준다! 나머지는 괜찮아요 .. !! – Batrickparry