Comparison between "enumeration" and "enumeration class" instances

Source: Internet
Author: User

Enumeration class

========================================================== ==============

/// <Summary>
/// Configuration type enumeration class
/// </Summary>
Public class configtype
{
// Configuration type name
Private int configtype;

// Private structure ensures the closeness of value ranges
Private configtype (INT configtype)
{
This. configtype = configtype;
}
/// <Summary>
/// Email-related configuration
/// </Summary>
Public static readonly configtype email = new configtype (1 );
/// <Summary>
/// File operation configuration
/// </Summary>
Public static readonly configtype file = new configtype (2 );
/// <Summary>
/// Points related configuration
/// </Summary>
Public static readonly configtype integral = new configtype (3 );
/// <Summary>
/// Configure meta information on the page
/// </Summary>
Public static readonly configtype meta = new configtype (4 );
/// <Summary>
/// Message-related configuration
/// </Summary>
Public static readonly configtype message = new configtype (5 );
/// <Summary>
/// User-related configuration
/// </Summary>
Public static readonly configtype user = new configtype (6 );

/// <Summary>
/// Rewrite the tostring Method
/// </Summary>
/// <Returns> return attribute value </returns>
Public override string tostring ()
{
Return configtype. tostring ();
}
/// <Summary>
/// Rewrite the equals Method
/// </Summary>
/// <Param name = "OBJ"> object to be compared </param>
/// <Returns> comparison result </returns>
Public override bool equals (Object OBJ)
{
Configtype Ct = OBJ as configtype;
If (OBJ = NULL) return false;
Return configtype = CT. configtype;
}
/// <Summary>
/// Override the gethashcode Method
/// </Summary>
/// <Returns> return the result value of int type </returns>
Public override int gethashcode ()
{
Return configtype. gethashcode ();
}

}

 

Enumeration

========================================================== ==========

Public Enum configtype
{< br> [description ("Email Related configuration")]
email = 1,
[description ("file operation related configuration")]
file = 2,
[description ("point related configuration")]
integral = 3,
[description ("Page meta information configuration")]
meta = 4,
[description ("message-related configuration")]
message = 5,
[description ("user-related configuration")]
User = 6
}

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.