C
C#2y ago
Down

❔ conversion operator

someone wanna explain what is the difference between implicit and explicit operator?
6 Replies
Relevant
Relevant2y ago
Console.WriteLine(7), the int is implicitly converted to a string
TheRanger
TheRanger2y 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
TheRanger2y ago
example u can only explicitly cast a float to int, but cannot implicitly cast it
Down
DownOP2y ago
thanks
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server