C# program to get the maximum number of generations that the system currently supports (GC.MaxGeneration Property)

C# GC.MaxGeneration Property: Here, we are going to learn how to get the maximum number of generations that the system currently supports in C#.Net?
Submitted by Nidhi, on May 23, 2021

The MaxGeneration property of the GC class is used to get the maximum number of generations that the system currently supports.

Syntax:

    public static int MaxGeneration { get; }

Return value:

It returns the maximum number of supported generations.

Program:

The source code to get the maximum number of generations that the system currently supports is given below. The given program is compiled and executed successfully.

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Total number of HEAP generations are: " + GC.MaxGeneration);
            Console.WriteLine();
        }
    }
}

Output:

Total number of HEAP generations are: 2

Press any key to continue . . .

C# Garbage Collection (GC Class) Programs »


ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




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.