Reputation: 4895
Currently getting an error with the below code, and I don't know how to fix it!
This is the error:
Cannot assign to 'Add' because it is a 'method group'
Here is my App.xaml.cs:
public partial class App : Application
{
//Public list of users and form can access
List<User> LoggedUsers = new List<User>();
//First startup of the application
public void Application_Startup(object sender, StartupEventArgs e)
{
//First startup, display the login form
LoginWindow FirstLogin = new LoginWindow();
FirstLogin.ShowDialog();
//If the login form was closed properly, handle the user
if (FirstLogin.DialogResult == true)
{
//Add the user to the list of logged users
User returned = FirstLogin.returnUser;
//Create temp duplicate for testing
User tmp = new User();
tmp.Email = "[email protected]";
tmp.FirstName = "John";
tmp.LastName = "Johnson";
tmp.ID = "01";
tmp.Permissions = 1;
LoggedUsers.Add = tmp;
LoggedUsers.Add = returned;
}
}
}
And here is my LoginWindow.xaml.cs which the User Object is returned from when closed (returned):
//Give App access to user object outside of this form
public User returnUser
{
get
{
return user;
}
}
//Public user object, start empty
User user = new User();
//Check the login
private void doLogin(string username, string password)
{
//User logged in, add data to user object
user.Email = "[email protected]";
user.FirstName = "John";
user.LastName = "Johnson";
user.ID = "01";
user.Permissions = 1;
//Close the form with dialog result "true"
this.DialogResult = true;
this.Close();
}
And the class, incase you need that:
//Logged in users class
Public Class User
{
public string ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public Int16 Permissions { get; set; }
}
Adding a duplicate object to the List for some testing purposes when I have fixed this.
Upvotes: 0
Views: 500
Reputation: 300759
List.Add()
is a method not a property:
LoggedUsers.Add(tmp);
LoggedUsers.Add(returned);
Upvotes: 7