1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Web.Http.ValueProviders.Providers;5 6 namespaceConsoleApp7 {8 Internal class Program9 {Ten Private Static voidMain (string[] args) One { A varDIC =Newdictionary<string,string> - { -{"Contact . Name","Zhang San"}, the{"Contact . Phoneno","123456789"}, -{"Contact . EmailAddress","[email protected]"}, -{"Contact . Address.province","Shanghai"}, -{"Contact . Address.city","Shanghai"}, +{"Contact . Address.district","changning"}, -{"Contact . Address.street","No. No. 968 Jinzhong Road"} + }; A varValueprovider =NewNamevaluepairsvalueprovider (DIC. ToArray (),NULL); at - //prefix= "" -Console.WriteLine ("Prefix: <Empty>"); -Console.WriteLine ("{0,-14}{1}","Key","value"); - varKeys = Valueprovider.getkeysfromprefix (string. Empty); - foreach(varIteminchkeys) in { -Console.WriteLine ("{0,-14}{1}", item. Key, item. Value); to } + - //prefix= "Contact" theConsole.WriteLine ("prefix:contact"); *Console.WriteLine ("{0,-14}{1}","Key","value"); $Keys = Valueprovider.getkeysfromprefix (" Contact");Panax Notoginseng foreach(varIteminchkeys) - { theConsole.WriteLine ("{0,-14}{1}", item. Key, item. Value); + } A the //prefix= "Contact" +Console.WriteLine ("prefix:contact. Address"); -Console.WriteLine ("{0,-14}{1}","Key","value"); $Keys = Valueprovider.getkeysfromprefix ("Contact . Address"); $ foreach(varIteminchkeys) - { -Console.WriteLine ("{0,-14}{1}", item. Key, item. Value); the } - Wuyi Console.read (); the } - } Wu}
Gets the key of the specified prefix through the Namevaluepairsvalueprovider object