C # Compiler Optimization credit? Questions about Code related to generics

Source: Internet
Author: User

In some of the code I designed, the code for customizing serialized objects is as follows:

Code

For (INT I = 0; I <this. Entities. length; I ++)
{
// Here, when T is a structure type, it can still be processed normally. In fact, the struct cannot be compared with null.
// The Judgment condition may be optimized when the compilation system is compiled, that is, this. entities [I] = NULL does not exist.
If (this. entities [I] = NULL)
{
Stream. writebyte (0); // null
Continue;
}
Else
{
Stream. writebyte (1); // not null
Writeentity (stream, this. entities [I]);
}
}

 

The definition of entities is public T [] entities {Get; set;}. all instances of the serialization class or structure can work normally.

You can only make the above guesses if you cannot find the cause for the moment.

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.