You think two different methods/techniques should exhibit identical behaviour? Why? (If they did, why would we have both?)
– Damien_The_UnbelieverApr 04 '19 at 06:52
Your first code snippet says "variable 'a' is an integer", which it is not, so it raises an error. The second one does convert the string into an integer, so it does work. If you are from vbnet background, the first code is similar to a `DirectCast`. .NET does not try to convert data unless you tell it to do so.
– CleptusApr 04 '19 at 06:55
hi @Damien_The_Unbeliever. Sure there is difference. But I am unable to figure out those differences will you please explain so that I can grasp those differences?.
– AnonymousApr 04 '19 at 07:04
.net is hard typed and has some implicit castings allowed... That means "conversion between similar data types". Other casting can not be done without a explicit conversion (AKA, your `Convert.ToInt32()` call). For example, for the different numeric types you can check [this table](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/implicit-numeric-conversions-table) There are also other implicit castings, not related to primitive data types, like a child class and the class it inherits from. You could do `Car myCar; Vehicle myVehicle = (Vehicle) myCar;`
– CleptusApr 04 '19 at 07:25