strange compile error!

J

Jeff

Hey

asp.net 2.0

This line of code:

MembershipUserCollection onlineUsers = Membership.GetAllUsers;

In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}

Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke the
method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\ContentMaster.master.cs 20 52
C:\...\Helloworld\

The code is placed in a master page...

I don't understand what I'm doing wrong here...

Any suggestions?
 
C

Chris Mullins

Jeff said:
This line of code:
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
[...]

You're going to laugh (or cry):
MembershipUserCollection onlineUsers = Membership.GetAllUsers();

Having that "()" there is what you need. This drove me nuts for a while, as
VB.Net doesn't need it and I got in the habit of omitting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top