How can I do?

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...?
 
P

Paulo

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!
 
G

Guest

Howdy,

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

Regards
 
G

Guest

Howdy,

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

Regards
 
G

Guest

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top