[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Explicit,Implicit keyword usage in C#

Posted on 2007-11-20
2
Medium Priority
?
968 Views
Last Modified: 2013-12-17
What is the use of Explicit as well as Implicit keyword in c#?
0
Comment
Question by:Rahamathulla_J
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
multithreading earned 1000 total points
ID: 20319327
Read the article for sample code and usage/syntax.

Once you have the syntax, know this ...

You use "explicit" when you want the person to use a cast to invoke your type conversion.
You use "implicit" when you want the type conversion to happen silently.
Use the built-in types as your guide. For example, you don't need an explicit cast to go from short to int, or int to long, but you do need an explicit cast to go from long to int, or int to short. This is because in one direction information loss is unlikely, while in the other direction it is highly probable. So, loss of information is one reason to require a cast. The other reason is to prevent any magical errors: If a reasonable person using your class could be surprised to learn that he had accidently changed types, you definately should have used Explicit.

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question