我正在使用字典来保存一些参数,我发现不可能序列化任何实现IDictionary的东西(无法序列化IDictionary).
作为一种解决方法,我想将字典转换为字符串以进行序列化,然后在需要时转换回字典.
因为我正在努力改进我的LINQ,这似乎是一个很好的地方,但我不知道如何开始.
这是我在没有LINQ的情况下实现的方法:
/// <summary>
/// Get / Set the extended properties of the FTPS processor
/// </summary>
/// <remarks>Can't serialize the Dictionary object so convert to a string (http://msdn.microsoft.com/en-us/library/ms950721.aspx)</remarks>
public Dictionary<string, string> FtpsExtendedProperties
{
get
{
Dictionary<string, string> dict = new Dictionary<string, string>();
// Get the Key value pairs from the string
string[] kvpArray = m_FtpsExtendedProperties.Split('|');
foreach (string kvp in kvpArray)
{
// Seperate the key and value to build the dictionary
string[] pair = kvp.Split(','); …Run Code Online (Sandbox Code Playgroud)