I have 2 lists as following:
ApproverListBE appList1;
ApproverListBE appList2 ;
I want to add the above 2 lists.How do I override the + operator.
As Bruce has said, adding lists is not a simple concept. There are three
different set operations available:
Union
The result set contains all the items from both operand sets
Intersection
The result set contains those items that are common to both operand sets
Difference
The result set contains the inverse of an Intersection; those items that are
only found in one or other of the operand sets.
You should also consider whether you want the 'addition' to append one list
to another or to merge the two lists in some implicit order.
For the sanity of those who might have to maintain your code in later years,
I would suggest you do not use operator overloading, but instead use Append
and Merge instance methods; and possibly Union, Intersection and Difference
static methods that take two lists as arguments and return a resulting list.
Joanna