When you create a small program the previous day, you need to use remoting to create a group of images on the server side, the client operates on the data group using the method provided by the server through remoting. The program prototype is as follows:
Object:
Public class employe
{
Private int _ id;
Private string _ name;
Public int ID
{
Get {return this. _ id ;}
Set {This. _ id = value ;}
}
Public string name
{
Get {return this. _ name ;}
Set {This. _ name = value ;}
}
}
The server has this data group:
List <employe> employes;
The following methods are provided:
Removeemploye (employe );
The actual situation is:
Public removeemploye (employe)
{
Employes. Remove (employe );
}
It seems that there is no problem in the program. However, when the program is busy, it cannot remove the embedded employe.
In the future, how can the objects on the client end be equal to those on the client server?
Add the following generation scheme to the employe class to solve the problem:
Public override int gethashcode ()
{
Return this. Id. gethashcode ();
}
Public override bool equals (Object OBJ)
{
Return this. gethashcode (). Equals (OBJ as employe). gethashcode ());
}
Originally, when the client-side objects are uploaded to the server, they must first pass the serializable method before deserializable. NET must tell whether the two objects are equal than the other objects.