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

  • SEARCH
  • Home
  • 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 8036803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:44:25+00:00 2026-06-05T02:44:25+00:00

Why can not coexist in the same class two operators (explicit and implicit) of

  • 0

Why can not coexist in the same class two operators (explicit and implicit) of the same type? Suppose I have the following:

public class Fahrenheit
{
    public float Degrees { get; set; }

    public Fahrenheit(float degrees) 
    {
        Degrees = degrees;
    }

    public static explicit operator Celsius(Fahrenheit f)
    {
        return new Celsius(ToCelsius(f.Degrees));
    }

    public static implicit operator Celsius(Fahrenheit f)
    {
        return new Celsius(ToCelsius(f.Degrees));
    }
}

public class Celsius {
    public float Degrees { get; set; }
    public Celsius(float degrees) 
    {
        Degrees = degrees;
    }

}

So I can give the client the possibility that use of either of two ways, for example:

Fahrenheit f = new Fahrenheit(20);
Celsius c1 = (Celsius)f;
Celsius c2 = f;

Is there any special reason why this is not allowed or is it just a convention to avoid a misuse of the programmer?

  • 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-06-05T02:44:26+00:00Added an answer on June 5, 2026 at 2:44 am

    According to Overloading Implicit and Explicit Operators page:

    That’s correct. Defining an implicit operator also allows for
    explicit conversion. Defining an explicit operator allows only for
    explicit conversion.

    Thus, if you define an explicit operator, you can do the following:

    Thing thing = (Thing)"value";

    If you define an implicit operator, you can still do the above, but
    you can also take advantage of implicit conversion:

    Thing thing = "value";

    So in short, explicit allows only explicit conversion, while implicit
    allows both explicit and implicit… hence the reason you can only
    define one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can not call many function: Zend_View_Helper helpers : MainHelpers.php Class Zend_View_Helper_MainHelpers { public function
I can not work this out. I have a class library called 'ABC.Service'. In
Can not run following SQL from ant's sql task : BEGIN DBMS_AQADM.CREATE_QUEUE_TABLE( queue_table =>
I can not for the life of me figure this out. I have made
I can not get the right result from the following code block: object ob
Can not deserialize following object graph. That Exception occurs when deserialize method called on
I can not compile, this program is giving me errors. I have already spend
I can not remove nodes while I iterate them thats ok.´ I have a
I can not tell if this is working but I have a script which
Can not parse json using this var res = eval('(' + response + ')');

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.