C# How to get properties names of generic class using nameof without specifing a type. I have class as follow:
public class Example<T> where T : class
{
public DateTime CreatedAt { get; set; } = DateTime.Now;
}
And I want to get "CreateAt" as string using following:
nameof(Example<>.CreatedAt)
but it doesn't work, I need to specify the type:
nameof(Example<int>.CreatedAt)
Although, for checking the type I can use construction:
typeof(BaseEntity<>)
Why it doesn't work with nameof? Why do I need to define the type?