Default method
In C#, every class is inherit from System.object class and System.object class contains four methods• Equals
• GetHashCode
• GetType
• ToString
So for every class which is made in c#, these above methods are default methods. Only three methods are overridable so you can override only three methods into derive class.
• Equals
• GetHashCode
• ToString
Example
public class Employee
{
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
return base.ToString();
}
}
No comments:
Post a Comment