⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch1_09.cs

📁 《c#技术内幕代码》
💻 CS
字号:
using System;
using System.Collections;

class CH1_9 {

   public static void Main() 
   {
	// Create a hashtable with a default comparison operator
	// and initially 10 elements.
	
	Hashtable ht = new Hashtable(10);
	
	// Add ten strings to the hashtable associated with a
	// key value (integer).
	
	ht.Add( 100, "Science");
	ht.Add( 200, "Math");
	ht.Add( 300, "English");
	ht.Add( 400, "History");
	ht.Add( 500, "Gym");
	
	// How many elements does the table contain?
	Console.WriteLine("The hashtable contains {0} elements", ht.Count);
	
	// Does it contain the entry for Gym? How about Recess?
	Console.WriteLine("The hashtable contains 500? {0}", ht.Contains(500));
	Console.WriteLine("The hashtable contains 600? {0}", ht.Contains(600));
	
	// What is the value for 400? 800?
	Console.WriteLine("The value for 400 is {0}", ht[400]);
	Console.WriteLine("The value for 800 is {0}", ht[800]);
	
	// See if the values are null
	if ( ht[400] == null )
	   Console.WriteLine( "Entry 400 is null" );
	else
	   Console.WriteLine( "Entry 400 is NOT null" );
	   
	if ( ht[800] == null )
	   Console.WriteLine( "Entry 800 is null" );
	else
	   Console.WriteLine( "Entry 800 is NOT null" );

   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -