Convert a String to a Number using the TryParse method

preview_player
Показать описание
You will see an example of how to use the tryParse method to convert a string to a int.

Example from MS
Рекомендации по теме
Комментарии
Автор

Oh goshhhh. You have no idea how you made it very simple. thank you very very

amadoucamara
Автор

Thanks for this. Just what I was looking for.

marknicholls
Автор

very cool vid!! Explained very well. Thanks!!

tomaina
Автор

Great video!
You can make the int theNumber inside the tryParse like this.

if (int.tryParse(theNumberAsAString, out int theNumber))
{

}

and remove the int theNumber from line 16.
I was just wondering is there anything bad with doing this or does it work just as good as declaring the int outside of the tryParse?

apeking
Автор

Really helpful bro keep up the good work.

kinginthenorth
Автор

what if my string is a word or phrase such as yes or no and I want to allocate a numerical value to it... can i do it with TryParse()?

christhemexvet
Автор

am i doing it wrong if i use Convert.To ?

ddddaaddaaaa