How can I do?

  • Thread starter Thread starter Mark Rae [MVP]
  • Start date Start date
M

Mark Rae [MVP]

Hi, what is the best form doing that? any way to do a if on 1 line,
example:

int MyInteger = MyBoolean ? 1 : 0;

However, this very quickly becomes very difficult to read...

What's the problem with more than one line, AAMOI...?
 
Hi, what is the best form doing that? any way to do a if on 1 line, example:

if (txtValorBene.Text.Trim() != "")
arParams[116] = new SqlParameter("@ValorBeneficio",
decimal.Parse(txtValorBene.Text.Trim()) ;
else
arParams[116] = new SqlParameter("@ValorBeneficio", decimal.zero) ;

I dont know if there is some way: arParams[116] = new
SqlParameter("@ValorBeneficio", if != "" decimal.parse(txt), else another
thing, etc..);

Thanks a lot!
 
Howdy,

decimal value;
arParams[116] = new SqlParameter(
"@ValorBeneficio",
Decimal.TryParse(decimal.Parse(txtValorBene.Text.Trim(), out value) ? value
: Decimal.Zero);

Regards
 
Howdy,

decimal value;
arParams[116] = new SqlParameter(
"@ValorBeneficio",
Decimal.TryParse(txtValorBene.Text.Trim(), out value) ? value :
Decimal.Zero);

Regards
 
Please ignore this post. Second one beneath is correct.
--
Milosz


Milosz Skalecki said:
Howdy,

decimal value;
arParams[116] = new SqlParameter(
"@ValorBeneficio",
Decimal.TryParse(decimal.Parse(txtValorBene.Text.Trim(), out value) ? value
: Decimal.Zero);

Regards

--
Milosz


Paulo said:
Hi, what is the best form doing that? any way to do a if on 1 line, example:

if (txtValorBene.Text.Trim() != "")
arParams[116] = new SqlParameter("@ValorBeneficio",
decimal.Parse(txtValorBene.Text.Trim()) ;
else
arParams[116] = new SqlParameter("@ValorBeneficio", decimal.zero) ;

I dont know if there is some way: arParams[116] = new
SqlParameter("@ValorBeneficio", if != "" decimal.parse(txt), else another
thing, etc..);

Thanks a lot!
 
Back
Top