帮解决个问题,看看下面代码哪有问题,为什么没有输出结果。谢谢

在博客园里找的代码但不输出结果,我不知道哪写错了,帮忙看一下。谢谢 EmployeeID类

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

namespace ConsoleApplication1
{
 public  class EmployeeID
    {

     public EmployeeID()
     {
     }
     private string ID { get; set; }
     public EmployeeID(string id)
     {
       
         this.ID = id;
     }
     public override string ToString()
     {
         return base.ToString();
     }
     public override int GetHashCode()
     {
         return base.GetHashCode();
     }
     public override bool Equals(object obj)
     {
         EmployeeID emp = obj as EmployeeID;
         if (emp == null) return false;
         if (this.ID == emp.ID) return true;
         return false;
     }
    }
}

EmployeeData类 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { public class EmployeeData { public EmployeeData() { // } public string Name { get; set; } public int Age { get ; set ; } public string Gender { get; set; } public EmployeeData(string name, int age, string gender) { this.Name = name; this.Age = age; this.Gender = gender; } } } 输出窗口: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Hashtable hst = new Hashtable(); hst.Add(new EmployeeID("0"),new EmployeeData("a",12,"female")); hst.Add(new EmployeeID("1"),new EmployeeData("b",10,"male")); hst.Add(new EmployeeID("2"), new EmployeeData("c", 10, "female")); abc: Console.WriteLine("Please input the employee ID:"); string userid= Console.ReadLine(); if (userid.Trim() != "exit") { EmployeeData emp = (EmployeeData)hst[new EmployeeID(userid.Trim())]; if (emp != null) { Console.WriteLine(emp.Name); Console.WriteLine(emp.Age); Console.WriteLine(emp.Gender); } goto abc; } } } } 帮看看哪有问题,不能输出HashTable 值。谢谢
posted @ 2009-07-16 16:32  画方软件  阅读(169)  评论(0)    收藏  举报