Sure! Here's an example of a UserLogin class with constructor overloading in C#:

C#
public class UserLogin
{
    public string Username { get; private set; }
    public string Password { get; private set; }

    // Default constructor
    public UserLogin()
    {
        // Set default values
        Username = string.Empty;
        Password = string.Empty;
    }

    // Constructor with username and password parameters
    public UserLogin(string username, string password)
    {
        Username = username;
        Password = password;
    }

    // Constructor with username parameter only
    public UserLogin(string username)
    {
        Username = username;
        Password = string.Empty; // Set password to empty string by default
    }
}

In this example, the UserLogin class has three constructors:

  1. The default constructor initializes the Username and Password properties with empty strings.

  2. The second constructor takes username and password parameters and sets the corresponding properties accordingly.

  3. The third constructor takes a username parameter only and sets the Username property with the provided value, while the Password property is set to an empty string by default.

You can create UserLogin objects using different constructor variations depending on your requirements. Here are some usage examples:

C#
// Create a UserLogin object using the default constructor
UserLogin user1 = new UserLogin();

// Create a UserLogin object with a username and password
UserLogin user2 = new UserLogin("johnsmith", "password123");

// Create a UserLogin object with a username only
UserLogin user3 = new UserLogin("janedoe");