Re: c# interview question
- From: "glenn" <glenn.csharp@xxxxxxxxxxx>
- Date: Mon, 12 Mar 2007 10:17:23 -0000
Peter
You could argue they're testing the depth of knowledge by asking the
question, but I do agree, I wouldn't like to work for a company that
constantly questioned my choice of string concatenation technique.
Glenn
"Peter Bradley" <pbradley@xxxxxxxxxx> wrote in message
news:%23iXnH1IZHHA.4940@xxxxxxxxxxxxxxxxxxxxxxx
My guess - and it is just a guess - is that the implicit cast probably
uses the ToString() method anyway. I would have thought any difference
between the two would have been optimized away by the compiler, but what
do I know?
One thing's for sure, if you (or rather your prospective employers) need
to worry about performance at this level, then they're using the wrong
language. To me, it's on a par with worrying about whether:
i++;
is more efficient than:
++i;
Who cares. If you're writing code where these differences are
significant, use C or C++, or even Assembly language.
Just my 2c. YMMV.
Peter
"Steve Bugden" <SteveBugden@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:606BB626-8DDC-40CD-87F7-7A9B00608284@xxxxxxxxxxxxxxxx
Hi,
I recently had an interview where I was asked a number of questions on
C#.
Unfortunately I didn't get the answers from the test and find that one of
them is still niggling me.
It was something like this:
Consider the following code:
int i = 0;
Console.WriteLine("The value is: " + i);
Console.WriteLine("The value is: " + i.ToString());
Which would you use to write an integer to the console and why would it
give
better performance?
I said I would use: Console.WriteLine("The value is: " +
i.ToString());
But I can't think why this should give a performance advantage. I can
only
guess that the compiler should be able to realise that a string is
required
from the integer for the line not using the ToString() method and
generate
the same MSIL.
Can anyone please enlighten me?
Best Regards,
Steve
.
- References:
- Re: c# interview question
- From: Peter Bradley
- Re: c# interview question
- Prev by Date: Re: c# interview question
- Next by Date: SQLexpress newbie question
- Previous by thread: Re: c# interview question
- Next by thread: Re: c# interview question
- Index(es):
Relevant Pages
|
Loading