using System.Collections.Generic;
public class Program { public static void Main() { Console.WriteLine("Hello World"); } }
public interface IFieldRetriever<T>
IDictionary<string, T> GetFields();
public class CustomerDto<T> : IFieldRetriever<T>
public string Name { get; set; }
public int age { get; set; }
public IDictionary<string, T> GetFields()
var dictFields = new Dictionary<string, T>();
foreach (var property in typeof(CustomerDto<>).MakeGenericType(typeof(T)).GetProperties())
var value = property.GetValue(this);
if (value == null && typeof(T).IsValueType)
value = Activator.CreateInstance<T>();
dictFields.Add(property.Name, (T)value!);