Foreach in C#

Posted on 2010-09-21
Last Modified: 2013-12-16
I am new to C#. Not sure what is wrong here.
Error      1      Foreach cannot operate on a 'method group'. Did you intend to invoke the 'method group'?      

namespace Test_Csharp
    public partial class Form1 : Form
        public Form1()

        private void btnGetfilename_Click(object sender, EventArgs e)
            DirectoryInfo work_dir = new DirectoryInfo("C:\\Documents and Settings\\test\\Desktop\\test");

            foreach (FileInfo fn in work_dir.GetFiles)

Question by:VBdotnet2005
  • 2
LVL 22

Expert Comment

ID: 33727678
foreach (FileInfo fn in work_dir.GetFiles())
LVL 22

Accepted Solution

p_davis earned 125 total points
ID: 33727681
you forgot the parenthesis for the method call

Author Closing Comment

ID: 33727688

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net WebRequest Code from JSON curl 7 50
Help with preventing selection from a combobox 11 34
IEnumerable<T> to a List<T> 8 37
VB.NET Textbox input validation 4 37
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question