I have a classA that has some public properties & overrides TosString method to to concatenate strings in these properties. It also has a property that returns int key;
I am using
string str = value1 + value2 + value3;
each value has # separated properties of classA
string[] values = Regex.Split(str,'#');
foreach(classA value in values)
{
dictionary.add(value.key, value);
}
This works fine
=====================================================================
For this scenario I want to use
values.ToDictionary
Can any one suggest how to use this?
It occurs to me that you might really want is to get the properties from a class and turn them into key-value pairs in a dictionary.
If that’s what you’re looking to do then Class -> String -> Array -> Dictionary is taking the long way.
If that’s the case maybe you want to try a more direct approach
Given a class like this
The following creates a dictionary variable named result.
And outputs this