adplus-dvertising
frame-decoration

Question

Which of the following statements is correct about the C#.NET code snippet given below?

int a = 10; 
int b = 20; 
int c = 30;
enum color: byte
{
    red = a, 
    green = b,
    blue = c 
}

a.

Variables cannot be assigned to enum elements.

b.

Variables can be assigned to any one of the enum elements.

c.

Variables can be assigned only to the first enum element.

d.

Values assigned to enum elements must always be successive values.

Posted under C# programming

Answer: (a).Variables cannot be assigned to enum elements.

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following statements is correct about the C#.NET code snippet given below?

Similar Questions

Discover Related MCQs

Q. Which of the following statements is true about an enum used in C#.NET?

Q. An enum that is declared inside a class, struct, namespace or interface is treated as public.

Q. An enum can be declared inside a class, struct, namespace or interface.

Q. Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?

Q. Which of the following statements is correct about an enum used in C#.NET?

Q. Choose the correct statement among the followings?

Q. Choose the keyword which declares the indexer?

Q. Choose the operator/operators which is/are not used to access the [] operator in indexers?

Q. Choose the correct statement among the following?

Q. Which among the following are the advantages of using indexers?

Q. Choose the correct statement about properties describing the indexers?

Q. Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?

Q. Choose the correct option among the following indexers which correctly allows to index in same way as an array?

Q. Choose the wrong statement about the properties used in C#.NET?

Q. Choose the statements which makes use of essential properties rather than making data member public in C#.NET?

Q. Where the properties can be declared?

Q. Select the modifiers which can be used with the properties?

Q. Choose the correct statements about write-only properties in C#.NET?

Q. Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail.Which of the follwing is the correct

Q. Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail.Which among the following is the correct solution to ensure this functionality?