→ O2000:string this[string Key] 01/16 09:02
→ ssccg:不懂你問題在哪,HttpRequest裡面的Form是個property 01/16 14:16
→ ssccg:type是NameValueCollection,用 Form[] 則是呼叫這個 01/16 14:16
→ ssccg:NameValueCollection的indexer 01/16 14:16
public class User
{
public string Name;
public string Phone;
}
public class UserCollection
{
private List<User> user;
public UserCollection()
{
user = new List<User>();
}
public User this[string name]
{
get { return ; } // 傳回 List<User> 中 Name 為 name 的 User Class
}
public List<User> AllUser
{
get { return user;}
}
}
UserCollection member = new UserCollection();
User jack = member["Jack"]; //取得 Jack 的資料
List<User> AllMember = member.AllUser; // 取得所有使用者資料
原本想的是能不能用 member 回傳所有使用者資料?
不過打完這篇好像忽然懂大大說的,不可能用 member 取得所有使用者資料。
再請問大大,上面的做法好嗎?用 List<T> 來存 Class
※ 編輯: On1earth 來自: 111.243.191.58 (01/16 21:49)
→ Litfal:用Dictionary。除非你是想做Manager class。 01/17 00:42
→ On1earth:謝謝大大,我了解了,用Dictionary比較方便 01/18 02:02