Bird
0
0

Find the mistake in this code:

medium📝 Debug Q7 of 15
C Sharp (C#) - LINQ Fundamentals

Find the mistake in this code:

var data = new List<int> { 5, 10, 15 };
var avg = data.Sum / data.Count();
Console.WriteLine(avg);
ACount() should be Count without parentheses
BSum is missing parentheses to call the method
CList initialization is incorrect
DConsole.WriteLine cannot print variables
Step-by-Step Solution
Solution:
  1. Step 1: Check Sum method usage

    Sum is a method and must be called with parentheses: Sum().
  2. Step 2: Verify Count() usage

    Count() is correctly called with parentheses.
  3. Final Answer:

    Sum is missing parentheses to call the method -> Option B
  4. Quick Check:

    Method calls need () [OK]
Quick Trick: Use () after Sum and Count to call methods [OK]
Common Mistakes:
MISTAKES
  • Forgetting () after Sum
  • Using Count without ()
  • Incorrect list syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes