Home » .Net

int structure and its methods in C#

Learn: int 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.

int 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 int structure:

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

1) int.Equals()

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

2) int.Parse()

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

3) int.MaxValue

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

4) int.MinValue

This is a get property of int structure. It returns maximum possible value of int 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;
            int val;

            val = int.Parse("12345");

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

            flag = int.Equals(123345, 123347);

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

            else
                Console.WriteLine("Both are not equal");

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

Above program produce following result:

Output

Value is : 125
Both are not equal
MaxValue of byte : 2147483647
MinValue of byte : -2147483648





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



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.