Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7054557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:38:30+00:00 2026-05-28T03:38:30+00:00

Suppose I have these two ctors: public SomeClass(string a, Color? c = null, Font

  • 0

Suppose I have these two ctors:

public SomeClass(string a, Color? c = null, Font d = null)
        {
            // ...
        }

public SomeClass(string a, Font c = null, Color? d = null)
        {
            // ...
        }

~and I do this:

SomeClass sc = new SomeClass("Lorem ipsum");

I’ll get this: “Error 1 The call is ambiguous between the following methods or properties […]”

It seems apparent to me that it doesn’t matter which one I refer to as the end result is the same (at least in this particular case, and to me that’s all that matters right now), so what are my options to getting around this?

EDIT 1:
@oltman: Simplified example.

I just want to be able to write

[...] new SomeClass("Lorem", Color.Green)

instead of

[...] new SomeClass("Lorem", null, Color.Green)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:38:31+00:00Added an answer on May 28, 2026 at 3:38 am

    Both constructors take the same number of arguments, but in a different order. Since you have specified default values for the two constructor parameters the compiler cannot distinguish between the two overloads when the second argument is not supplied.

    I would advise you to remove the existing constructors and replace with the following:

    public SomeClass(string a, Color? color, Font font)
    {
        // constructor implementation
    }
    
    public SomeClass(string a) : this(a, null, null) {}
    public SomeClass(string a, Color color) : this(a, color, null) {}
    public SomeClass(string a, Font font) : this(a, null, font) {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have these two tables: Invoice ------- iInvoiceID int PK not null dtCompleted
Suppose we have declared these two classes: public class Animal { //..... } public
Suppose I have a socket. What is the difference between these two lines of
Suppose I have two containers of elements: std::vector<std::string> foo = { aa, bb, cc
Suppose I have these two tables : TABLEA TABLEB ----------- ----------- ID | NAME
Suppose I have a dataset with those two immortal tables: Employee & Order Emp
Suppose you have two linked servers called Local and Remote respectively. Is there a
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.