The Artima Developer Community
Sponsored Link

.NET Buzz Forum
.NET Trivia #1

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Avery

Posts: 1206
Nickname: james615
Registered: Sep, 2003

James Avery is a .NET pimp
.NET Trivia #1 Posted: Nov 21, 2005 7:17 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by James Avery.
Original Post: .NET Trivia #1
Feed Title: .Avery Blog
Feed URL: /blog/Install/BlogNotConfiguredError.aspx
Feed Description: .NET and everything nice
Latest .NET Buzz Posts
Latest .NET Buzz Posts by James Avery
Latest Posts From .Avery Blog

Advertisement

Dave and I have been doing alot of interviews lately (well, mostly Dave), and from this atmosphere of knowledge assessment I have started thinking about good .NET trivia questions. These aren’t questions we actually ask in the interview (quit trying to cheat) but instead questions that cover the same kind of things. It helps that I have been re-reading Richter’s book (along with my friend Jayme) and we have fun trying to come up with questions the other can’t answer.

I thought it might be fun to post some of these here… so here goes.

Given the following piece of code:

int x = 1;
object.ReferenceEquals(x, x);

What will ReferenceEquals return (either true or false)

Scroll down the for answer

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

*

It will return false. Why? Well, ReferenceEquals compares two objects… and since object is a reference type and integers are value types each of the parameters are boxed separately when passed into the method. Since it is boxed into separate spots on the heap the reference addresses won’t be the same and the method returns false.

Confused? Check out these resource on reference types, value types, and the stack and the heap:

Type Fundamentals – Jeffrey Richter
Value Types – Chris Brumme

-James

 

Read: .NET Trivia #1

Topic: GhostDoc v1.9 Released Previous Topic   Next Topic Topic: WinFX November CTP is Here?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use