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-minvalue-field/

字节结构的最小值字段用于表示字节数据类型的最小可能值。该字段的值为常量意味着用户不能更改该字段的值。该字段的值为 0 。

语法:

public const byte MinValue = 0;

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

例:

// C# program to illustrate the
// Byte.MinValue field
using System;

class GFG {

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

        // Taking an array of the
        // integers
        int[] num = {12, 45, 1235, 5342};

        // taking variable of Byte type
        byte mynum;

        foreach(int n in num)
        {

            if (n >= Byte.MinValue && n <= Byte.MaxValue)
            {

                // using the method of Convert class
                mynum = Convert.ToByte(n);

                Console.WriteLine("Conversion is Possible.");
            }

            else 
            {
                Console.WriteLine("Not Possible");
            }
        }
    }
}

输出:

Minimum Value is: 0
Conversion is Possible.
Conversion is Possible.
Not Possible
Not Possible

参考:

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


相关教程