Solved

c# Cannot convert method group

Posted on 2011-02-15
6
1,227 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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