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
}
}
}
- To define a variable of type enum color in Main(), we should use the statement, color c; .
- enum color being private it cannot be used in Main().
- We must declare enum color as public to be able to use it outside the class Sample.
- To define a variable of type enum color in Main(), we should use the statement, Sample.color c; .
- We must declare private enum color outside the class to be able to use it in Main().
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.
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.
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers