Home »
MCQs »
C# MCQs
What is the correct syntax to declare a variable in C#?
21. What is the correct syntax to declare a variable in C#?
- type variableName = value;
- type variableName;
- variableName as type = value;
- Both A. and B.
Answer: D) Both A. and B.
Explanation:
The both of the above syntaxes can be used to declare a variable:
- type variableName = value; - It defines the type and assigns the value
- type variableName; - It defines the type only