There are a few words that we rarely use in day to day C# practices [I'm focusing readers who are beginners]. But I've seen them in either online exams or other IT quiz shows. So I came to write something about those untouched keywords. Below is the list of these keywords
- Implicit
- Explicit
- Volatile
- Checked
- Unchecked
- Const vs ReadOnly [The most frequently asked Interview question for C# programmer]
Lets get to know about them which one is used
where and when:
Implicit
The implicit keyword is used to declare an implicit user-defined type conversion
operator. Implicit conversion operators can be called implicitly, without being
specified by explicit casts in the source code. It eliminates unnecessary casts,
implicit conversions can improve source code readability.
The below example you can see we've a CustomType that takes Integer value as its
initializing value and after defining the Implicit operator It becomes directly
castable to int.

However, because implicit conversions can occur without the programmer's
specifying them, care must be taken to prevent unpleasant surprises. In general,
implicit conversion operators should never throw exceptions and never lose
information so that they can be used safely without the programmer's awareness.
Explicit
As I mentioned sometimes implicit conversion can surprise you as it can go
unnoticed. So in a case you want to enforce an casting to be explicit then
Explicit keyword is there. Again The explicit keyword is used to declare an
explicit user-defined type conversion operator.
class MyType
{
public static explicit operator MyType(int i)
{
//
code to convert from int to MyType
}
}
Unlike Implicit, it enforces the explicit cast to mention when a type is
declared with conversion operator.

Volatile:
Volatile is kept under the category of Modifiers. The volatile keyword indicates
that a field can be modified in the program by something such as the operating
system, the hardware, or a concurrently executing thread.
Syntax:
public volatile int i;
Behavior: The system always reads the current value of a volatile object
at the point it is requested, even if the previous instruction asked for a value
from the same object. Also, the value of the object is written immediately on
assignment. And due to such behavior volatile modifier is usually used for a
field that is accessed by multiple threads without using the lock statement to
serialize access. Using the volatilemodifier ensures that one thread retrieves
the most up-to-date value written by another thread.
The type of a field marked as volatile is restricted to the following types:
- Any reference type.
- Any pointer type (in an unsafe context).
- The types sbyte, byte, short, ushort, int, uint, char, float, bool.
- An enum type with an enum base type of byte, sbyte, short, ushort, int, or uint.
Checked and Unchecked:
Before we start I want to show you some code:


Vipul MalhotraPosted Jun 30, 2015, 11:27 AM
Great article..
Sam HobbsPosted Sep 18, 2011, 2:30 AM
I think that user-defined type conversions and the volatile keyword are not beginner topics. They certainly are not frequently asked about in C# Corner forum discussions.
John NolanPosted Sep 16, 2011, 7:41 AM
brilliant, thanks for going the extra mile and explaining these