If, Then Ranges in C#

Hello:

Below is an if, then statement in C# code.  How do I get the syntax for the “1030.00” piece to say: “If TotalAmountProcessedInSqFt is between 1.0 and 1.5, then return 1030.00”.  What would be the syntax for that?

Thanks!

TBSupport


if (_TOTALAMOUNTPROCESSEDINSQFT_<1.0)
{
          return "515.00";
}

if (_TOTALAMOUNTPROCESSEDINSQFT_ > 1.0 and _TOTALAMOUNTPROCESSEDINSQFT_
< 1.5)
{
          return "1030.00";
}

//if (__1_290.Trim().ToLower() == "x")
//{
//       return "1290.00";
//}

//if (__1_545.Trim().ToLower() == "x")
//{
//       return "1545.00";
//}

//if (__2_060.Trim().ToLower() == "x")
//{
//       return "2060.00";
//}

//if (__2_575.Trim().ToLower() == "x")
//{
//       return "2575.00";
//}

//if (__3_090.Trim().ToLower() == "x")
//{
//       return "3090.00";
//}

return "";

Open in new window

LVL 1
TBSupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun KlineLead Software EngineerCommented:
A simplified way would be:
if (_TOTALAMOUNTPROCESSEDINSQFT_<1.0)
           return "515.00";
else if (_TOTALAMOUNTPROCESSEDINSQFT_ < 1.5)
           return "1030.00";

Open in new window


The Else IF will happen only if the first condition is not met, and _TOTALAMOUNTPROCESSEDINSQFT_ < 1.5)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
>>“If TotalAmountProcessedInSqFt is between 1.0 and 1.5, then return 1030.00”.

if((TotalAmountProcessedInSqFt >= 1.0) && (TotalAmountProcessedInSqFt <= 1.5)
  {
  return "1030.00";
  }
TBSupportAuthor Commented:
Thanks, for the comments, everyone!  I should be talking to the client, this morning.  I will let you know how that goes.

TBSupport
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.