public interface IRecordInformation
{
DateTime CreatedOn { get; set; }
DateTime ModifiedOn { get; set; }
}
public class CareerApplication : IRecordInformation
{
public int CareerApplicationId { get; set; }
public string Name { get; set; }
public string FileName { get; set; }
public string Email { get; set; }
public DateTime IRecordInformation.CreatedOn { get; set; }
public DateTime IRecordInformation.ModifiedOn { get; set; }
}
Why i am doing this ? Because if i change the interface and remove a property then there should be compile time error that there is no property declared in interface for which the implementation exist in class . This way i can remove the implementation from class . But if i dont use explicit implementation using interface name in class then if i remove a property from interface then that corresponding property will be treated as the property of class itself.
I have tried doing like
public DateTime CreatedOn { get => ((IRecordInformation)this).CreatedOn; set => ((IRecordInformation)this).CreatedOn = value; }
But there is a stack overflow exception for which i am attaching the image