這壹段C#代碼妳可以參考壹下:我想對妳有幫助
public class OthelloCast : List<string>
{
// Use a dictionary to contain
// cast names (key) and actor names (value).
public Dictionary<string, string> OthelloDict =
new Dictionary<string, string>();
public OthelloCast()
{
// Add data to the dictionary.
OthelloDict.Add("Bianca", "Gretchen Rivas");
OthelloDict.Add("Brabantio", "Carlos Lacerda");
OthelloDict.Add("Cassio", "Steve Masters");
OthelloDict.Add("Clown", "Michael Ludwig");
OthelloDict.Add("Desdemona", "Catherine Autier Miconi");
OthelloDict.Add("Duke of Venice", "Ken Circeo");
OthelloDict.Add("Emilia", "Eva Valverde");
OthelloDict.Add("Gratiano", "Akos Kozari");
OthelloDict.Add("Iago", "Darius Stasevicius");
OthelloDict.Add("Lodovico", "Fernando Souza");
OthelloDict.Add("Montano", "Jeff Hay");
OthelloDict.Add("Othello", "Marco Tanara");
OthelloDict.Add("Roderigo", "Pedro Ruivo");
// Populate the list with character names.
foreach (KeyValuePair<string, string> kvp in OthelloDict)
{
this.Add(kvp.Key);
}
}