首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

这个简单程序为什么不是小弟我想要的结果呢,请

2012-01-15 
这个简单程序为什么不是我想要的结果呢,请高手指点。using Systemusing System.Collections.Genericusing

这个简单程序为什么不是我想要的结果呢,请高手指点。
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);

热点排行