Solved

c# Cannot convert method group

Posted on 2011-02-15
6
1,217 Views
Last Modified: 2012-05-11
how can  I fix this problem

Error      1      Cannot convert method group 'Extract_Emails' to non-delegate type 'string[]'. Did you intend to invoke the method?      C:\Users\¿¿¿7\documents\visual studio 2010\Projects\emailsearch\emailsearch\Form1.cs      37      34      emailsearch


if(!string.IsNullOrEmpty(result))
                {
                    Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
                    EmailsList = helper.Extract_Emails;

                }
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Coderbuddy
{
    public class ExtractEmails
    {
        private string s;
        public ExtractEmails(string Text2Scrape)
        {
            this.s = Text2Scrape;
        }
        public string[] Extract_Emails()
        {
            string[] Email_List = new string[0];
            Regex r = new Regex(@"[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}", RegexOptions.IgnoreCase);
            Match m;
            //Searching for the text that matches the above regular expression(which only matches email addresses)
            for (m = r.Match(s); m.Success; m = m.NextMatch())
            {
                //This section here demonstartes Dynamic arrays
                if (m.Value.Length > 0)
                {
                    //Resize the array Email_List by incrementing it by 1, to save the next result
                    Array.Resize(ref Email_List, Email_List.Length + 1);
                    Email_List[Email_List.Length - 1] = m.Value;
                }
            }
            return Email_List;
        }
    }
}

Open in new window

0
Comment
Question by:teera
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 34894688
You are returing a list of strings, and you try to put it in a single string.

Try this:

if(!string.IsNullOrEmpty(result))
                {
                    Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
                    string[] EmailsList = helper.Extract_Emails;

                }
0
 

Author Comment

by:teera
ID: 34894722
Hi Dhaest
delemailed.png
0
 

Author Comment

by:teera
ID: 34894741
i try
EmailsList = helper.Extract_Emails();
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 34894756
Damn, I overlooked at it :)

When calling a function, you'll need () at the end :)

string[] EmailsList ;

if(!string.IsNullOrEmpty(result))
                {
                    Coderbuddy.ExtractEmails helper = new Coderbuddy.ExtractEmails(result);
                    EmailsList = helper.Extract_Emails();

                }
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 34894871
Did it solve your problem ?
0
 

Author Closing Comment

by:teera
ID: 34904339
Thank you
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

832 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