日期:2014-05-18  浏览次数:20793 次

这个简单程序为什么不是我想要的结果呢,请高手指点。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication17
{
  class Program
  {
  static void Main(string[] args)
  {
  Hashtable phones = new Hashtable();
  // Add items.
  phones.Add("John", "123-4567");
  phones.Add("Enju", "351-8765");
  phones.Add("Molly", "221-5678");
  phones.Add("James", "010-4077");
  phones.Add("Ahmed", "110-5699");
  phones.Add("Leah", "922-5699");

  // Iterate through the collection.
  System.Console.WriteLine("Name\t\tNumber");
  foreach (DictionaryEntry de in phones)
  {
  System.Console.WriteLine("\t:(0),\t(1)",de.Key,de.Value);
  }
  }
  }
}

Name Number
  :(0), (1)
  :(0), (1)
  :(0), (1)
  :(0), (1)
  :(0), (1)
  :(0), (1)
请按任意键继续. . .



------解决方案--------------------
System.Console.WriteLine("\t:(0),\t(1)",de.Key,de.Value); 

改成
System.Console.WriteLine("\t:{0},\t{1}",de.Key,de.Value);