Home »
.Net »
C# Programs
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 »