Q:

C# program to demonstrate the #region preprocessor directive

0

C# program to demonstrate the #region preprocessor directive

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to demonstrate the #region preprocessor directive is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to demonstrate the #region preprocessor directive.
using System;

class Program
{
   public static void Main()
   {
        Console.WriteLine("Before Region");
#region RegionCountries
	Console.WriteLine("\tIndia");
	Console.WriteLine("\tAustralia");
	Console.WriteLine("\tAmerica");
	Console.WriteLine("\tEngland");
#endregion
        Console.WriteLine("After Region");
   }
}

Output:

Before Region
        India
        Australia
        America
        England
After Region
Press any key to continue . . .

Explanation:

In the above program, we created a class Program that contains the Main() method. Here, we created a region that contains some statements using the #region preprocessor directive.

Using the #region preprocessor directive, we can create a region in the code using the #region preprocessor directive. The #region directive is used to organize the code, it cannot overlap a #if directive.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now