C# Programming - Enumerations - Discussion

Discussion Forum : Enumerations - General Questions (Q.No. 15)
15.
Which of the following statements are correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
( 
class Sample
{ 
    private enum color : int
    { 
        red, 
        green, 
        blue
    }
    public void fun()
    {
        Console.WriteLine(color.red); 
    }
}
class Program
{ 
    static void Main(string[ ] args)
    { 
        // Use enum color here
    } 
} 
}
  1. To define a variable of type enum color in Main(), we should use the statement, color c; .
  2. enum color being private it cannot be used in Main().
  3. We must declare enum color as public to be able to use it outside the class Sample.
  4. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; .
  5. We must declare private enum color outside the class to be able to use it in Main().
1, 2, 3
2, 3, 4
3, 4
4, 5
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Vaishnav said:   1 decade ago
Its wrong,To define a variable of type enum color in Main(), we should use the statement, Sample.color c;

We can not use private enum in other class as Sample.color c

Because color is a private enum.

Surenthar said:   1 decade ago
We can not use private enum in other class as Sample.color c.

Because color is a private enum.

Vishwanath Heddoori said:   4 years ago
The Correct options are (2, 3).

Vishwanath Heddoori said:   4 years ago
The Correct options are (2, 3).

Post your comments here:

Your comments will be displayed after verification.