In an interface, we can define a property and later implement it. However, the issue I recently encountered is that if we define a ‘list’ or ‘array’, we must ultimately implement the properties as private.
In contrast, for int or string, we do not have this problem and can write them as public.
Why?!
for exm :
interface IEmployee
{
string Name{get; set;}
List<string> Friends
}
public class Employee : IEmployee
{
.
.
.
public Name{get;set;} // Must be public *****
List<string> IEmployee.Friends { get ; set ; } // Must Be Private through IEmployee *****
.
.
.
}
New contributor
Matin Baki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.