Is there a difference between datarow.length == 0 and datarow == n

L

lianqtlit

Is there a difference between datarow.length == 0 and datarow == null in
terms of performance?
 
N

Nicholas Paldino [.NET/C# MVP]

Well, I would expect the datarow == null to be more performant, as it is
less operations. The former comparison has to make the call to the
property/field, and then perform the comparison whereas the latter is just
checking the reference to see if it is null.

However, this is comparing apples to oranges, since you are not making
to comparisons that have the same semantics, so the previous point is pretty
moot.

Also, I think this could easily be considered a severe case of
micro-optimization.
 
L

lianqtlit

Thanks

Nicholas Paldino said:
Well, I would expect the datarow == null to be more performant, as it is
less operations. The former comparison has to make the call to the
property/field, and then perform the comparison whereas the latter is just
checking the reference to see if it is null.

However, this is comparing apples to oranges, since you are not making
to comparisons that have the same semantics, so the previous point is pretty
moot.

Also, I think this could easily be considered a severe case of
micro-optimization.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

lianqtlit said:
Is there a difference between datarow.length == 0 and datarow == null in
terms of performance?
 
R

Rick Lones

lianqtlit said:
Is there a difference between datarow.length == 0 and datarow == null in
terms of performance?

If datarow does indeed == null, then would not attempting to access
datarow.length throw an exception?

-rick-
 
L

lianqtlit

yah!! your right thanks... rick

Rick Lones said:
If datarow does indeed == null, then would not attempting to access
datarow.length throw an exception?

-rick-
 

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