Input string was not in a correct format | FormatException was unhandled in C#

preview_player
Показать описание
Hello Friends,

Today our topic is on Input string was not in a correct format Or FormatException was unhandled in C#.

When we are converting from one value to another and during conversion we face such type of errors if input value was not in a correct format.

For Example:-
-----------------
string str="World";
int i=Convert.ToInt32(str);

So when this above line executes then it will throw Input string was not in a correct format Or FormatException was unhandled because we can't convert a string value(World) to int value. So let's change this code,

string str="123";
int i=Convert.ToInt32(str);

Now, when this above line executes then it will work absolutely fine because we can convert a string value(123) to int value.

During the conversion we just need to take care of input value.

Wish You Success,
#VCreations Tech.
Рекомендации по теме
Комментарии
Автор

Input string was not in a correct format in сисяп, ахахахаха

hardmakertv