Solved

Foreach in C#

Posted on 2010-09-21
3
1,547 Views
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()
        {
            InitializeComponent();
        }

        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)
            {
                MessageBox.Show(fn.Name);
            }

        }
    }
}
0
Comment
Question by:VBdotnet2005
  • 2
3 Comments
 
LVL 22

Expert Comment

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

Accepted Solution

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

Author Closing Comment

by:VBdotnet2005
ID: 33727688
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

680 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