Thursday 15 January 2015

Transfering equations from Excel To C# -



Transfering equations from Excel To C# -

i'm trying convert excel spreadsheet little programme made c#.

the equation have on excel is:

if(s6>=3.55;1;if(s6>2.25;0.8;if(s6>1.61;0.65;0.5)))

where s6 cell value check written.

i tried following:

if (width>=3.55) { double radius = 1.0; else if (width>2.25 ) { double radius = 0.8; } else if (width>1.6 ) { double radius = 0.65; } else { double radius = 0.5; } }

but doesn't work, i'm missing, how should declare variable radius dependent of variable width? message on c# says cannot declare variable "radius" in current scope, should declare variable before loop? msdn help file utilize fixed value homecoming statement within if statement, means cannot have variable dependency within if{} loop?also, there other more effective way kind of conditional logic?

an if block not contain else/else if statements. need close original if statement first. also, declaring local variable in each scope , not using doesn't create sense. want declare radius outside scope of of if/else blocks

double radius; if (width>=3.55) { radius = 1.0; } else if (width>2.25 ) { radius = 0.8; } else if (width>1.6 ) { radius = 0.65; } else { radius = 0.5; }

c# excel

No comments:

Post a Comment