Convert code from vb to c#?

Hello friends,

am trying to multiply the data from two columns from the same excel but am not sure where the structure of my code is going wrong, tried changing some () to but to no avail.
I got the code from another thread which I can’t find anymore but it was originally in VB

Code placed in the assign is
Convert.ToString(Convert.ToInt32(row[“Possible Setups”].ToString)*Convert.ToInt32(row[“F1”].ToString))

Code I used for reference in VB was

You code form is not right
Use this
Convert.ToString( Convert.ToInt64(row["Possible Setups"])*Convert.ToInt64(row["F1"]))

1 Like


in c# ToString method needs round brackets ():
Convert.ToString(Convert.ToInt32(row[“Possible Setups”].ToString()) * Convert.ToInt32(row[“F1”].ToString() ));


1 Like

Thanks for your responses @Lakshay_Verma and @q.gio!
And yeah you were right it was my fault I was missing the curved brackets!

1 Like

It is just a miss.
And just from learning perspective, avoid any unnecessary conversion.
For ex. Object does not need to be converted to sting and then to Integer.

Happy Automation


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.