I’m trying to convert int row to string in excel
Are you trying to convert String to interger right ?
Are you facing any issue here ?
Convert.ToInt32(row(2).ToString) try this buddy @Loka625
the one you are using is find buddy
It says input string is not in correct format
Buddy may i know where that row comes from whether a for each row loop or for each loop
for each row loop
data is read from excel, used for each row loop, to loop through all the columns in excel, one of those columns is Row column with integer values
try this alone buddy, this should work actually as you are going good
yah got it buddy @Loka625 , actually the problem occurs when the assignment meets this row
and it has empty value in it, so while trying to convert that as integer we were geting error like string " " cannot be converted to integer
So in that just use a validation before assigning in_Rownumber with a if condition like this
- if condition like this
if this condition passes, in then part of if condition assign like how you do now
else assign with
in_Rownumber = 0
Thats all buddy you are done. Kindly try and let know buddy @Loka625
Did that work buddy @Loka625
I will test it and let you know, thanks
You can use
Int32 var; boolean Success_or_not = Int32.TryParse(" ",var); Writeline - var.ToString(); // 0
Int32.TryParse() method returns if the conversion succeeded, contains the 32-bit signed integer value equivalent of the number contained in a string or zero if the conversion failed. The conversion fails if the s parameter is null or Empty.