C
C#3y ago
Down

❔ conversion operator

someone wanna explain what is the difference between implicit and explicit operator?
6 Replies
Relevant
Relevant3y ago
Console.WriteLine(7), the int is implicitly converted to a string
TheRanger
TheRanger3y ago
not really, thats just calls 7.ToString() in the inside implicit is basically when the compiler casts for you without writing the cast eg
object foo = 1; // implicit
object bar = (object)1; // explicit
object foo = 1; // implicit
object bar = (object)1; // explicit
that can be limited with some types, u can explicitly cast a type, but cannot implicitly cast it, and vice versa
TheRanger
TheRanger3y ago
example u can only explicitly cast a float to int, but cannot implicitly cast it
Down
DownOP3y ago
thanks
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?