Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

Some Interview questions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
weird0 - 12 Jul 2007 07:31 GMT
Why did u use stringbuilder instead of string for appending?

I told him it is more efficient. He did not seem very convinced. So
what should have been the exact answer.

How many objects will be formed in the operation a=b+c; ? (a,b and c
are objects)

 What is the difference between a pointer and reference ?

a ptr can be null but a ref cannot be null... please elaborate .. i
cant understand thru some code examples to clear my concept...

Unemployed
Jon Skeet [C# MVP] - 12 Jul 2007 08:04 GMT
>  Why did u use stringbuilder instead of string for appending?
>
> I told him it is more efficient. He did not seem very convinced. So
> what should have been the exact answer.

Could you say what your code actually was? Sometimes StringBuilder is
more efficient - sometimes it isn't.

See http://pobox.com/~skeet/csharp/stringbuilder.html for more
information.

>  How many objects will be formed in the operation a=b+c; ? (a,b and c
> are objects)

It will depend on what the objects actually are.

>   What is the difference between a pointer and reference ?
>
>  a ptr can be null but a ref cannot be null... please elaborate .. i
> cant understand thru some code examples to clear my concept...

A reference certainly can be null - in C#, at least. In C#, pointers
are only used in unsafe code.

Jon
weird0 - 12 Jul 2007 14:39 GMT
Suppose if the objects a,b and c are (three cases):-
1.int
2.float
3.belong to user-defined class like Date
Jon Skeet [C# MVP] - 12 Jul 2007 14:44 GMT
> Suppose if the objects a,b and c are (three cases):-
> 1.int
> 2.float
> 3.belong to user-defined class like Date

If they're all ints, no objects will be created.
If they're all floats, no objects will be created.
Not sure what you mean by Date - if you mean DateTime, it's a struct
and you'd get a compile-time error because you can't add two DateTimes
together.

Jon
PS - 12 Jul 2007 15:15 GMT
> Why did u use stringbuilder instead of string for appending?
>
> I told him it is more efficient. He did not seem very convinced. So
> what should have been the exact answer.

If that is YOUR reason to use a StringBuilder then it is the correct answer
in some respects. I use a StringBuilder if it makes the code cleaner and
easier to understand what is happening. Performance (if improved) is an
added benefit but it is not my primary reason to use it.

> How many objects will be formed in the operation a=b+c; ? (a,b and c
> are objects)
[quoted text clipped - 3 lines]
> a ptr can be null but a ref cannot be null... please elaborate .. i
> cant understand thru some code examples to clear my concept...

These last 2 questions seem pointless to me. I really don't know what they
are trying to ascertain from asking questions like this. At least the first
one finds out something of your rationale about your coding style.

The first question I like to ask is "Have you read Design Patterns?"

PS

> Unemployed
Samuel R. Neff - 13 Jul 2007 18:52 GMT
We always ask about design patterns too but it's amazing how many
people can explain exactly what they are and give textbook responses
of their impelmentation, but then 2 seconds later choose not to use
them in an example where they obviously apply.

Sam

------------------------------------------------------------
We're hiring!  B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC.  Work with a variety of technologies
in a relaxed team environment.  See ads on Dice.com.

>> Why did u use stringbuilder instead of string for appending?
>>
[quoted text clipped - 23 lines]
>
>> Unemployed
Helge Jensen - 16 Jul 2007 20:04 GMT
Samuel R. Neff skrev:
> We always ask about design patterns too but it's amazing how many
> people can explain exactly what they are and give textbook responses
> of their impelmentation, but then 2 seconds later choose not to use
> them in an example where they obviously apply.

Or use them where they are obviously overengineered solutions to
problems that aren't there :)

Signature

Helge


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.