Microsoft Interview Question for Software Engineer in Tests






Comment hidden because of low score. Click to expand.
0
of 0 vote

In C# readonly allows initializing and modifying the value in constructor.

- guest June 28, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In addition, a const of a reference type other than string can only be initialized with null (hence, const only make sense if of a value type or string). And only data members (class level variables) can be readonly.

- Anonymous July 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

still i'm not clear...someone explain the difference clearly...thank you.

- donkeyMan August 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

C# Readonly allows you to initialize variable in Constructor, whereas Constant value should be specified at compile time. Constant values may be stored in register as optimization whereas Readonly variables are allocated memory in same way as any normal variable

- Mallik August 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

linke - stackoverflow.com/questions/55984/what-is-the-difference-between-const-and-readonly

- anon December 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Constant is a compile-time constant, and read-only is runtime constant.

- fiddler June 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1) A const cannot be static,while readonly can be static.
2) A const need to be declared and initialized at declaration only,while a readonly can be initialized at declaration or by the code in the constructor.
3) A const's value is evaluated at design time,while a readonly's value is evaluated at runtime.

- Vidhi May 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Constant is a compile-time constant and will be inlined by the compile. This is why constants should be private or internal to avoid dependecy issues. It can contain only value types, except of string and null.

A readonly will be initialized either at its declaration or within the constructor and is not restricated to value types. Its value can only be changed via reflection.

- Boris August 31, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More