Difficulty: Easy
Correct Answer: e.name = 'Amol'; e.age = 25; e.sal = 5500;
Explanation:
Introduction / Context:
The question checks familiarity with C# field assignment syntax versus constructs from other languages (VB, C/C++).
Given Data / Assumptions:
Concept / Approach:
In C#, field assignment uses the dot operator on the variable: e.name = "Amol"; e.age = 25; e.sal = 5500; Features like With blocks are from VB, and the arrow operator is from C/C++ pointer syntax, neither of which applies to C# field assignment.
Step-by-Step Solution:
e.name
, e.age
, e.sal
with standard assignment.Avoid VB-style With
or C/C++ ->
syntax; they are invalid in C#.
Verification / Alternative check:
Compile only the candidate from Option A; it succeeds. The others produce syntax errors in C#.
Why Other Options Are Wrong:
e
); invalid context for assignments.
Common Pitfalls:
Bringing habits from other languages into C# syntax.
Final Answer:
e.name = 'Amol'; e.age = 25; e.sal = 5500;
Discussion & Comments