byte structure and its methods in C#

Learn: byte structure and its strategies in C#.Net, it’s a predefined structure of .Net system; here we will talk about its techniques and properties with example.

a byte is a pre-characterized structure of .NET system class library. Also, as we realize that each structure in the .NET system contains a few techniques and properties to work on it.

There are the following significant techniques for byte structure:

  1. byte.Equals()
  2. byte.Parse()
  3. byte.MaxValue
  4. byte.MinValue

1) byte.Equals

This technique is utilized to check two given byte object are equivalent or not. It returns a boolean outcome.

2) byte.Parse()

This strategy is utilized to change over or parse the string to byte.

3) byte.MaxValue

This is a get property of byte structure. It returns the greatest conceivable estimation of byte variable.

4) byte.MinValue

This is a get property of byte structure. It returns the greatest conceivable estimation of byte variable.

All the above technique can without much of a stretch comprehend with the assistance of the program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool flag = false;
            byte val;

            val = byte.Parse("125");

            Console.WriteLine("Value is : "+val);

            flag = byte.Equals(123,125);

            if(flag == true)
                Console.WriteLine("Both are equal");
            else
                Console.WriteLine("Both are not equal");

            Console.WriteLine("MaxValue of byte : " + byte.MaxValue);
            Console.WriteLine("MinValue of byte : " + byte.MinValue);
        }
    }
}

Above program produce the following outcome

Output:

Value is : 125
Both are not equal
MaxValue of byte : 255
MinValue of byte : 0

Leave a Comment

error: Alert: Content is protected!!