What is better?

O

omtechguy

What is better in terms of performence and what is the reason?

dr.IsRecommendToFriend =
Boolean.Parse((Request["IsRecommendToFriend"].ToString().Equals("1")) ?
"true" : Request["IsRecommendToFriend"].ToString());

or

string IsRecommendToFriend =
Request["IsRecommendToFriend"].ToString();
dr.IsRecommendToFriend =
Boolean.Parse((IsRecommendToFriend.Equals("1")) ? "true" :
IsRecommendToFriend);

Any better way to write the above?
 
A

Arne Vajhøj

The best way to answer a performance question is to test the performance of
your available implementation choices in a real-world scenario.

It is the fastest way to get a result that looks more useful than
throwing a dice.

But in most cases the result is not more useful than throwing a
dice.

Getting results that truly reflects the performance for
the lifetime of the code is hard work.
The right way to write the code is to write it in a way that is most easily
understood and which does the best job helping anyone who might visit the
code later to avoid breaking it.

Yep.

Arne
 

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