What is the correct syntax to declare a variable in C#?

21. What is the correct syntax to declare a variable in C#?

  1. type variableName = value;
  2. type variableName;
  3. variableName as type = value;
  4. 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

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.