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 7770761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:29:16+00:00 2026-06-01T16:29:16+00:00

I have the following operator in my Visual WebPart’s codebehind file: public static implicit

  • 0

I have the following operator in my Visual WebPart’s codebehind file:

public static implicit operator TemplateControl
(ScholarChip.PaymentProcessor.PaymentProcessor.PaymentProcessor target)
    {
        return ((target == null) ? null : target.TemplateControl);
    }

I’m receiving the error:

User-defined conversion must convert to or from the enclosing type  

I’m unfamiliar with the above error. Can anyone suggest how I might rectify it? The code is being used in a Sharepoint 2010 Visual WebPart.

Thanks much:)

  • 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-01T16:29:16+00:00Added an answer on June 1, 2026 at 4:29 pm

    The problem is that you’re defining a conversion between PaymentProcessor and TemplateControl, but you’re not defining that conversion in either the PaymentProcessor class or the TemplateControl class. TemplateClass seems like it’s part of a framework, so I doubt you can define the conversion in that class.

    A user-defined conversion must be a member of one of the two types being converted (which is just another way of saying what the error message says). In other words, if you control the PaymentProcessor class, move the conversion into that class. If you control neither class, you’re out of luck, and you need to handle the conversion in a normal method.

    As an example, this will give the same compiler error you saw:

    class A {}
    class B {}
    class C
    {
        public static implicit operator A(B source) { return new A(); }
    }
    

    This will compile:

    class A {}
    class B
    {
        public static implicit operator A(B source) { return new A(); }
    }
    

    So will this:

    class A
    {
        public static implicit operator A(B source) { return new A(); }
    }
    class B {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: template <typename T> LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0);
I have the following code: template <class T> struct pointer { operator pointer<const T>()
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have the following code which compiles and runs fine under Visual Studio 2008
I have the following code: template <class T> static std::string ToString(const T& t) {
I have the following question: Assume base class A with method: A& operator+(A& a)
Suppose you have the following Generic class heirarchy: public abstract class GenericBase<T> { T
I have following static declaration of memory: void* array[5000]; How I can allocate the
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'

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.