using System; using System.CollectionsHashtable h= new Hashtable (); h.Add("A","AA");没问题
导入命名空间 using System.Collections;如果你把Hashtable new在类里面 就点不出来他的Add方法 要new在某个事件中就可以点出他的Add方法
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;public partial class Hashtable : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Hashtable ht = new Hashtable(); ht.add这就出不来了 没什么错吧
从你的命名来看Hashtable是网页的名字,你要用的是HashTable,注意大小写。
public class SamplesHashtable { public static void Main() { // Creates and initializes a new Hashtable. Hashtable myHT = new Hashtable(); myHT.Add("one", "The"); myHT.Add("two", "quick"); myHT.Add("three", "brown"); myHT.Add("four", "fox"); // Displays the Hashtable. Console.WriteLine("The Hashtable contains the following:"); PrintKeysAndValues(myHT); } public static void PrintKeysAndValues(Hashtable myHT) { Console.WriteLine("\t-KEY-\t-VALUE-"); foreach (DictionaryEntry de in myHT) Console.WriteLine("\t{0}:\t{1}", de.Key, de.Value); Console.WriteLine(); } }
using System.CollectionsHashtable h= new Hashtable ();
h.Add("A","AA");没问题
要new在某个事件中就可以点出他的Add方法
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class Hashtable : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Hashtable ht = new Hashtable();
ht.add这就出不来了 没什么错吧
{
public static void Main()
{
// Creates and initializes a new Hashtable.
Hashtable myHT = new Hashtable();
myHT.Add("one", "The");
myHT.Add("two", "quick");
myHT.Add("three", "brown");
myHT.Add("four", "fox"); // Displays the Hashtable.
Console.WriteLine("The Hashtable contains the following:");
PrintKeysAndValues(myHT);
}
public static void PrintKeysAndValues(Hashtable myHT)
{
Console.WriteLine("\t-KEY-\t-VALUE-");
foreach (DictionaryEntry de in myHT)
Console.WriteLine("\t{0}:\t{1}", de.Key, de.Value);
Console.WriteLine();
}
}