看板 C_Sharp 關於我們 聯絡資訊
參考了2樓的方法終於改寫出來了 推 s3748679:http://ppt.cc/oRmE 測試環境: C#2010 express public class Node : Dictionary<object,object> { public object Data{set;get;} public Node Add( object KEY ){ this.Add( KEY,new Node ); return this; } public Node this [object KEY] { get{ object RESULT; this.TryGetValue( KEY, out RESULT ); return RESULT; } } } 使用範例 Node ND = new Node(); ND.Add("KEY1"); ND["KEY1"].Add("KEY2"); ND["KEY1"]["KEY2"].Data = "Test String"; Console.WriteLine(ND["KEY1"]["KEY2"].Data); //out put : Test String -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 119.77.130.173 ※ 編輯: hello1988 來自: 119.77.130.173 (02/22 01:16) ※ 編輯: hello1988 來自: 119.77.130.173 (02/22 01:19) ※ 編輯: hello1988 來自: 119.77.130.173 (02/22 01:20)
soup514:Dictionary<object, Dictionary<object, object>> 02/22 21:23
soup514:這是我單純的想法,純粹使用[][]來取最後一個object 02/22 21:24
hello1988:可以 不過效果只有2層 02/26 21:05