Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 322273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:55:25+00:00 2026-05-12T08:55:25+00:00

I am writing some class and it wont compile without using System.Linq. But i

  • 0

I am writing some class and it wont compile without “using System.Linq”. But i don’t understand why its needed. What i am writing has nothing to do with Linq. How can i find out where a namespace is used?
And the very badly written piece of code (I am trying to figure out what i want it to do):

using System;
using System.Collections;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace DateFilename
{
  public class FailedFieldsList
  {
    private static List<FailedFields> ErrorList = new List<FailedFields>();
    public void AddErrorList(FailedFields errs)
    {
        ErrorList.Add(errs);
    }
    public void addSingleFailedField(string vField, string vMessage) 
    {
        //FailedFields
    }
    public List<FailedFields> GetErrorList()
    {
        return ErrorList;
    }
    public class FailedFields
    {
        public List<FailedField> ListOfFailedFieldsInOneRecord = new List<FailedField>();
        public class FailedField
        {
            public string fieldName;
            public string message;
            public FailedField(string vField, string vMessage)
            {
                this.fieldName = vField;
                this.message = vMessage;
            }
            public override string ToString()
            {
                return fieldName + ", " + message;
            }
        }
        public void addFailedField(FailedField f)
        {
            ListOfFailedFieldsInOneRecord.Add(f);
        }
        public int getFailedFieldsCount()
        {
            return ListOfFailedFieldsInOneRecord.Count();
        }
    }

  }
}

Error message produced when i dont include the linq namespace:
Error 4 Non-invocable member 'System.Collections.Generic.List<DateFilename.FailedFieldsList.FailedFields.FailedField>.Count' cannot be used like a method. D:\Slabo\My Documents\Visual Studio 2008\Projects\DateFilename\DateFilename\FailedFieldsList.cs 47 54 DateFilename

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:55:25+00:00Added an answer on May 12, 2026 at 8:55 am

    The problem is in the last method:

    public int getFailedFieldsCount() {
        return ListOfFailedFieldsInOneRecord.Count();
    }
    

    The method Count() is not a member of a List(T). The property Count, however, is. If you replace Count() by Count, this will compile without the need for using System.Linq.

    By including System.Linq, you enable the extension method Count(), which, confusingly enough, does exactly the same thing.

    See List(T) Members on msdn for a breakdown of what’s part of a List(T).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing some code to type strings using the Robot class. Everything is
In writing some threaded code, I've been using the ReaderWriterLockSlim class to handle synchronized
I am writing some unit test and I have a unit testing base class
I'm writing some callback implementation in C++. I have an abstract callback class, let's
I've got a method in a class that's writing to some string, which calls
I have some experience writing web applications in Java for class projects. My first
While making some final tests of a class-library that I'm writing for Windows Mobile
While writing some C code, I decided to compile it to assembly and read
This one has been puzzling my for some time now. Let's imagine a class
Greetings all. I am writing some code using the Boost Units library and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.