The use of User-Defined Conversions

Hi guys,

I am studying C# and there are a lot of things to cover as you know.  I consider myself as an intermediate level C# developer and my goal is to be an advanced C# developer.

I know what this conversion is.
If somebody asks me what the interface is, I might be able to explain it and go deeper with a few code examples.
However, if somebody asks me the same questions for User-Defined Conversions, I might be able to highlight what it is in a high level, but won't be able to explain with code examples.

I have developed C# applications a few times at work, but I have never used User-Defined Conversions.

Do you guys use this type of conversions often at work?

I am just wondering if I have to study this part like other parts(class, method, async, interface etc.) of C#, or skip it for now and come back when I absolutely need it.(but in most cases, I don't think this will happen) I am familiar with other types of conversions(implicit, explicit, check, uncheck, boxing, unboxing, using 'is' and 'as', reference conversions etc.)

C# experts! Please give me any advice.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Yes, I used this a couple of times in my apps.

user-defined conversions is nothing else than a implicit conversion function defined in your class, which defines in on your class level what conversions are possible from within your class to some "external" class.

so if you know exactly what a explicit conversion function is, you know everything about that functionality
Jacques Bourgeois (James Burger)PresidentCommented:
I have been programming for 40 years, half 25 of them professionally, in different languages and environment, with applications that go from text processing to database to graphics to services to you name it. I have been programming in .NET since the first beta versions.

And I never had to use a custom conversion. I bet most programmers do not even ever heard the term before.

So, in my opinion, to answer your question, "come back when I absolutely need it".

Since it is rarely used, no need to be at ease with it. You know it exists, and that is sufficient for that kind of stuff. You will fall back on it if you ever need it. This is the case with a lot of features in modern languages. Operator overloading is one that comes to my mind.

Knowing they are there and that they exists is a kind of security net. They are like these tools that have been lying at the bottom of a drawer in the woodworking shops for years, and that you bought just in case. You almost forgot what they are used for, but you see them from time to time when looking for something else, so they hang somewhere in the back of your mind. Then, one day, you have a problem, and you remember that you have exactly the little gizmo that can solve it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IzzyTwinklyAuthor Commented:
Hi James,

Thank you so much for your valuable advice. You have no idea how much your advice helped my situation.
Yes, I agree with your opinion on operator overloading too.
I guess that I've always known this but I really wanted to be confirmed by an expert like you.
From now on, I will skip/skim these kind of sections and focus on the essential skills.

Thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.