473,394 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

performance issue (Tech Questions)

Hi All,

I just wonder the differences between fallowings

if (myValue > 0)
{
DoThis();
}

&

if (myValue>0)
DoThis();

____________________________________
AND
____________________________________

If I call a variable with the "this" reference and if I call the same
variable without the "this" reference

i.e.

this.MyVariable

&

MyVariable

What are the advantages and disadvantages, if there are any...?
How it effect on the performance?

Thanks All

Nirosh.
Nov 15 '05 #1
2 1047
Champika Nirosh <cn*****@textcentric.lk> wrote:
I just wonder the differences between fallowings


<snip>

One thing to do when considering this kind of thing is to test it -
either benchmark it, or at least look at the difference in IL. So,
here's a test program:

using System;

public class Test
{
int x=5;

void Foo()
{
if (x > 10)
DoSomething();
}

void Bar()
{
if (this.x > 10)
{
DoSomething();
}
}

void DoSomething()
{
}

static void Main()
{
}
}

Now looking at the IL for Foo and Bar using ildasm you can see that the
code generated is exactly the same - so there can't be any performance
differences.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2
In addition to what Jon said, I would add that the curly brackets are there
only to group stataments that belong to if and have no effect on generated
code.

Miha
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tim Smith | last post by:
Hi, I have a table ORDER_DETAIL with 22 million rows which has an index of (person_id, code_id, created_dtt) I have another ORDER table with 5 million rows which has an index of (order_dtt,...
10
by: **ham | last post by:
I know that's an old dirty issue; GDI+ almost -the slowest part of the framework - has bothered many developers using it in animations. Even in managed C++ the performance is awful. Now, any dude...
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
109
by: MSG | last post by:
Michel Bardiaux <michel.bardiaux@peaktime.be> wrote in message news:<G4idnfgZ0ZfCWbrdRVn2jQ@giganews.com>... > Mark Shelor wrote: > > > > > OK, Sidney, I am considering it. I can certainly...
2
by: Champika Nirosh | last post by:
Hi All, Can some one shed some light on to the fallowing discussion.. The issure is.. Why we shouldn't use a seperate dll when we have the option to add the class (cs file) straightaway to...
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
13
by: General Fear | last post by:
Does anyone in this forum know of tech questions for an Access programmer? I have not been able to find a good web page with Access tech questions. I am interviewing Access programmers and want...
0
by: H - Recruiter - Testing | last post by:
Dear Candidate, Hope you are doing well. One of our CMM level 5 clients, SATYAM has urgent requirement for SR. PERFORMANCE TEST ENGG. Please mail your resume across ASAP with following details:...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.