Yesturday I was reading about parameterised constructors. I read "There are two types of calling methods one is implicit and other is explicit." I know the basic difference of syntax between these two. I just want to know is whether there is any difference between working of these two? How can we identify where to use implicit and where to use explicit? I think there should be something different in there working as we need to define it diffeterntly. Can you specify how they works? and which one to use where and why?
Thanks in advance.
> I just want to know is whether there is any difference between working of these two?
There is no difference between the two as far as their working is concerned. The only difference between the two is that a non-explicit constructor acts as an implicit type-conversion operator and may be invoked implicitly; an explicit constructor will not be used for implicit conversions.
> How can we identify where to use implicit and where to use explicit?
In general, any constructor that can be invoked with a single argument should be declared explicit. The exception is: it is your design intent to facilitate an implicit conversion via the constructor.
For more information, see: