New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Why can converticity type 'string' to 'int'?
3 Answers
+ 3
I think in C#, the best way is to use Int32.TryParse() method. It gives you an option to safely handle invalid values, without writing an extra try-catch block.
https://docs.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=netframework-4.8
+ 1
Java has a method: Integer.valueOf:
Integer.valueOf("100") -> 100
does C# have similar?
Or did you ask for something else?
0
I believe no.
Char to int sure.
String to int[] sure.