Why does it work?
Why fire the cast to interface type, after packaging significant of type int?
July 9th 19 at 14:03
How to handle JSON generated js-sortable?
How do I output the contents of the collection in the console?
How to call a function from a trait in this situation?
Are there any restrictions on the Colva request to the api of contact?
AP Kontinent + IPTables?
Where to start learning ADO.NET?
How to open a link in GoogleDocs?
How to upload the image to the local repository in the docker?
More answers about
"Why does it work?"
July 9th 19 at 14:05
Also Packed Int32 implement the IComparable interface, but Packed as Int32 was given to the Object type required the explicit castes to the interface type.
July 9th 19 at 14:07
System.Int32 implements IComparable
this is no exception.
But what about the packaging?
commented on July 9th 19 at 14:10
Eating... Well, it will happen, why it should break this mechanism?
commented on July 9th 19 at 14:13
Creates an object on the heap, the value of the int field is copied to this new object, and the object is cast to type object that does not implement the IComparable interface
commented on July 9th 19 at 14:16
Yes, but int does not cease to be an int-if that referenced object type.
In this case obj is reference type object that points to the Packed int. When you privtate it(the link) to IComparable, then Rantum looks at the place where it points to, and there is an int that knows what is IComparable.
I recommend reading about inheritance and addressing in memory.
commented on July 9th 19 at 14:19
commented on July 9th 19 at 14:22
commented on July 9th 19 at 14:25
I do not understand why with implicit custom gives a compilation error, but with obvious everything is OK
commented on July 9th 19 at 14:28
commented on July 9th 19 at 14:31
This allows to reduce the number of silly logic errors in the transformations, all otvestvennost for "strange" transformation lies on the shoulders of the programmer.
commented on July 9th 19 at 14:34
: "Explicit is better than implicit"
commented on July 9th 19 at 14:37
July 9th 19 at 14:09
When you write "number." in the last line the system has no idea what obj contains INTOSAI value and just shows the methods for the interface IComparable.
But this does not mean that the code will work )
to write your answer or comment.
Find more questions by tags