ObjectToDictionaryConverter.ToDictionary method

Converts an arbitrary object to a dictionary with string keys and string values.

public static Dictionary<string, string> ToDictionary(object? data)
parameter description
data The object to convert. Can be a dictionary, enumerable, or any object with public properties.

Return Value

A Dictionary with string keys and string values.

Remarks

Conversion behavior: - IDictionary: Converts keys and values to strings. - IEnumerable (excluding strings): Creates indexed keys like “item[0]”, “item[1]”, etc. - Other objects: Extracts public properties as key/value pairs.

See Also