I’m new to C# and learning new words. I find it difficult to understand what’s the meaning of these two words when it comes to programming c#.
I looked in the dictionary for the meaning and here’s what I got:
Implicit
“Something that is implicit is expressed in an indirect way.”
“If a quality or element is implicit in something, it is involved in it or is shown by it;”
Explicit
“Something that is explicit is expressed or shown clearly and openly, without any attempt to hide anything”
“If you are explicit about something, you speak about it very openly and clearly.”
I would like to understand it in C#.
Thanks for your help.
Cheers
additional info:
Here is a part of sentence in the book what I’m reading now which has this word “implicit”
“This means that Area and Occupants inside
AreaPerPerson( )implicitly refer to the copies of those variables found in the object that invokesAreaPerPerson( )“
I quite don’t understand what this sentence here trying to say.
The
implicitandexplicitkeywords in C# are used when declaring conversion operators. Let’s say that you have the following class:If you want to create a new
Roleand assign aNameto it, you will typically do it like this:Since it has only one property, it would perhaps be convenient if we could instead do it like this:
This means that we want to implicitly convert a string to a
Role(since there is no specific cast involved in the code). To achieve this, we add an implicit conversion operator:Another option is to implement an explicit conversion operator:
In this case, we cannot implicitly convert a string to a
Role, but we need to cast it in our code: