csharp Code:
class Student
{
public string StudentId { get; set; }
public float FeesPaid { get; set; }
public static Student operator +(Student student, float feesPaid)
{
student.FeesPaid += feesPaid;
return student;
}
public static Student operator +(float feesPaid, Student student)
{
student.FeesPaid += feesPaid;
return student;
}
}
Note that the operator is defined twice for the two different orders of the arguments. You only need to do that if you want to be able to use the operator with arguments in both orders rather than just the object before the value.