When using remoting, pay attention

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.