VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • C# | Byte。最大值字段

C# | Byte。最大值字段

原文:https://www.geeksforgeeks.org/c-sharp-byte-maxvalue-field/

字节结构的最大值字段用于表示字节数据类型的最大值。该字段的值为常量意味着用户不能更改该字段的值。该字段的值为 255。其十六进制值为 0xFF 。

语法:

public const byte MaxValue = 255;

返回值:该字段始终返回 255。

例:

// C# program to illustrate the
// Byte.MaxValue Field
using System;

class GFG {

    // Main Method
    static public void Main()
    {
        // display the Maximum
        // value of Byte struct
        Console.WriteLine("Maximum Value is: " + Byte.MaxValue);

        // taking a variable
        byte var1 = 255;

        if (var1.Equals(Byte.MaxValue)) 
        {
            Console.WriteLine("Equal..!!");
            Console.WriteLine("Type of var1 is: {0}",
                                 var1.GetTypeCode());
        }

        else 
        {
            Console.WriteLine("Not equal..!!");
            Console.WriteLine("Type of var1 is: {0}",
                                 var1.GetTypeCode());
        }
    }
}

输出:

Maximum Value is: 255
Equal..!!
Type of var1 is: Byte

参考:

  • https://docs。微软。com/en-us/dotnet/API/system。字节。maxvalue?视图=netstandard-2.1


相关教程