0

I have the following string expression which am trying to run ,But am getting error saying string format is not correct

for (i = diffvol; i < result.count; i++)
{
    B1Volume = Convert.ToDecimal(String.Format("result.Data[0].B{0}Volume", i));
    B2Volume = Convert.ToDecimal(String.Format("result.Data[0].B{0}Volume", i));
}
aloisdg
  • 22,270
  • 6
  • 85
  • 105
mahesh
  • 3,067
  • 16
  • 69
  • 127

1 Answers1

1

The error you are getting is related to the Convert.ToDecimal method, NOT the String.Format. The reason should be obvious: a string such as "result.Data[0].B0" is not the string representation of a number. A string such as "1407" would be one.

Florin Toader
  • 337
  • 1
  • 9