Solved

c# Cannot convert method group

Posted on 2011-02-15
6
1,243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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