convert dto to dictionary csharp

Code Example - convert dto to dictionary csharp

                
                        someObject.GetType()
     .GetProperties(BindingFlags.Instance | BindingFlags.Public)
          .ToDictionary(prop => prop.Name, prop => prop.GetValue(someObject, null))