PDA

View Full Version : سوال: debug کد دفترچه تلفن ساده در سی شارپ



bi enteha
شنبه 20 مهر 1392, 22:21 عصر
سلام دوستان
متاسفانه چون در نوشتن برنامه در سی شارپ مبتدی و کمتر مسلط به error های سی شارپ هستم
برای debug این کد به کمکتون نیازمندم
ممنون میشم اشکالات کارم رو برام قید کنید
در ضمن این کد قراره یه دفترچه تلفن ساده باشه که 5 گزینه داره:
1.اضافه کردن مشخصات فرد به لیست
2.سرچ
3.حذف یک فرد
4.پرینت کل دفترچه
5.خروج


[

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mohadese
{
struct contact
{
public string name;
public string family;
public string tel;
};

class csphonebook
{
List<contact> ph = new List<contact>();
void add()
{
contact x = new contact();
Console.WriteLine("name");
string N = Console.ReadLine();
Console.WriteLine("family");
string F = Console.ReadLine();
Console.WriteLine("tel");
string T = Console.ReadLine();
csphonebook add(N,F,T);
x.name = N;
x.family = F;
x.tel = T;
ph.Add(x);
}
void search()
{
Console.WriteLine("enter the name or family");
string S=Console.ReadLine();
for (int i = 0; i < ph.Count; i++)
{
if (ph[i].name == S || ph[i].family == S )
Console.WriteLine(ph[i]);

}

}
void DeleteByName()
{
Console.WriteLine("enter the name or family or telephone");
string N=Console.ReadLine();
for (int i = 0; i < ph.Count; i++)
{
if(ph[i].name== N || ph[i].family==N ||ph[i].tel==N)
ph.RemoveAt(i);
}
}
void printAll()
{
for(int i=0;i<ph.Count;i++)
Console.WriteLine(ph[i]);
}
int menu()
{
int number=0;
Console.WriteLine("please enter a number\n"+"if you want:\n"+"1. Add a person\n"+"2.search the number\n"+"3.delete a person\n"+"4.print All number\n"+"5.exist");
number = Convert.ToInt32(Console.ReadLine());
return number;
}
}
class Program
{
static void Main(string[] args);

public static string N;
public static string F;
public static string T;
public int number;
csphonebook st = new csphonebook();
st.menu();
if(number==1)
st.add();
if(Number==2)
st.search();
if(Number==3)
st.DeleteByName();
if(Number==4)
st.printAll();
if(Number==5)
return 0;


}
[/LEFT]
}