ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is the difference between readonly and constant in c#
 Question Submitted By :: Kiran
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between readonly and constant in c#
Answer
# 1
readonly value can be changed at runtime but constant never 
change entire application
 
Is This Answer Correct ?    7 Yes 0 No
Karunakar
 
  Re: What is the difference between readonly and constant in c#
Answer
# 2
A const must be initialized at the time of its creation. A
readonly field can be assigned to once in the class
constructor allowing you to pass in the value at run-time.
Declaring fields as const protects both you and other
programmers from accidentally changing the value of the
field. Also note that with const fields, the compiler
performs some optimization by not declaring any stack space
for the field. The readonly keyword is similar to const,
with two exceptions. First, the storage of a readonly field
is the same as a regular read-write field, and thus there is
no performance benefit. Secondly, readonly fields can be
initialized in the constructor of the containing class.

Use of the 'static' keyword, however, associates a field
with a class itself, so there will only ever be one such
field per class, regardless of the number of the class
instances (and the static field will exist even if there are
no class instances). A static field need not be constant,
however; it can be changed by code.
 
Is This Answer Correct ?    2 Yes 0 No
Anver Sadat
 
 
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
How to store image file in Sql server database? Unique-Software-Systems4
Can you override private virtual methods?  3
can we drive a class from delegate? InterGraph4
Where is the output of TextWriterTraceListener redirected?  1
When you inherit a protected class-level variable, who is it available to?  2
What?s an abstract class? NIIT2
What is ENUM? Wipro5
How do you inherit from a class in C#?  1
Diff b/w casting and boxing Wipro4
if i want to transmit binary data,,,will it be support by Webservices or any exceptions ? define  1
Which is the best institute in hyderabad to learn Sharepoint Portal?  7
Can property defined in Interface. Synechron1
I have a class declared as below public class a { public void add() {} } What is the diference between a a1 =new a; and simply a a1;  1
What are object oriented concepts? Microsoft2
syntax for writing private method in a interface Wipro7
class Employee { stat9c Method1() static Method2(ref a) stat9c Method3(out x) } class Employee { stat9c Method1() static Method2(ref a) stat9c Method3(out x) } what will happen & why?  2
What does the term immutable mean? Techno-Labs2
What are the the three types of DAO ?  1
When compiler adds a default constructor to a class? TCS3
Will finally block get executed if the 1exception had not occurred?  3
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com