Home » .Net

byte structure and its methods in C#

Learn: byte structure and its methods in C#.Net, it’s a predefined structure of .Net framework; here we are going to discuss its methods and properties with example.

byte is a pre-define structure of .NET framework class library. And as we know that every structure in .NET framework contains some methods and properties to operate on it.

There are following important methods of byte structure:

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

1) byte.Equals

This method is used to check two given byte object are equal or not. It returns boolean result.

2) byte.Parse()

This method is used to convert or parse string to byte.

3) byte.MaxValue

This is a get property of byte structure. It returns maximum possible value of byte variable.

4) byte.MinValue

This is a get property of byte structure. It returns maximum possible value of byte variable.

All above method can easily understand with the help of 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 following result:

Output

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL








Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.