Home » .Net

float structure and its methods in C#

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

float 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. float.Equals()
  2. float.Parse()
  3. float.MaxValue
  4. float.MinValue

1) float.Equals

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

2) float.Parse()

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

3) float.MaxValue

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

4) float.MinValue

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

            val = float.Parse("12.5");

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

            flag = char.Equals(123.25,123.25);

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

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

Above program produce following result:

Output

Value is : 12.5
Both are equal
MaxValue of byte : 3.402823E+38
MinValue of byte : -3.402823E+38





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.