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       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  Dot Net  >>  Dot Net Framework
 
 


 

 
 Dot Net Framework interview questions  Dot Net Framework Interview Questions
 Dot Net Remoting interview questions  Dot Net Remoting Interview Questions
 Dot Net WindowsForms interview questions  Dot Net WindowsForms Interview Questions
 Dot Net General interview questions  Dot Net General Interview Questions
 Dot Net AllOther interview questions  Dot Net AllOther Interview Questions
Question
What is the difference b/w constant & read only variable?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference b/w constant & read only variable?
Answer
# 1
Constant: The value of a constant variable is set at 
compile time and can't be reset again.

Readonly: Can be set in a constructor or can be reset again.
 
Is This Answer Correct ?    16 Yes 1 No
Test
 
  Re: What is the difference b/w constant & read only variable?
Answer
# 2
constant value set on initialization it not may be change or
reset when that readonly can be change in running time.
 
Is This Answer Correct ?    11 Yes 0 No
Dharmendra
 
 
 
  Re: What is the difference b/w constant & read only variable?
Answer
# 3
For Both Constants and Read only values, we can set values 
for them only once. 

In the case of Constants, we set the value at the compile 
time itself. After that we cannot change it

Example:

class Test
    {
        const double pi = 3.14;
        .......................
        .......................

    }

In the case of Read only data, we can set the value in the 
constructor.

Example:

class Test
    {
        private double _bonus;

        public Test(double bonus)
        {
            _bonus = bonus;
        }

        public double Bonus
        {
            get { return _bonus; }
        }

    }

Test a(5.25);
Test b(6.75);

In this case, at the time object creation, we can set the 
value for the bonus. That is, we can decide the value at 
the runtime. So a reaonly variable is also known as runtime 
constants.


So, the basic difference is, in the case of contstant, the 
value will be same across the objects of that class, but it 
may differ in the case of readonly variables.
 
Is This Answer Correct ?    11 Yes 0 No
Sumesh
 

 
 
 
Other Dot Net Framework Interview Questions
 
  Question Asked @ Answers
 
What does assert() method do?  1
Features in .net framework 1.1 ? Digital-GlobalSoft1
what is a round trip?What is a postback? Bosch2
If we want to construct our own Garbage collector what are the steps things we have to do? Honeywell3
what is .net? IBM12
how many ways for pass the parameters in the fuction in c#  3
How Garbage Collector identifies the objects which are not in use? Honeywell5
what is MVC pattern?  1
exe abrevatiom IBM4
What are the different authentication modes in the .NET environment?  2
What is CLR and how it generates native code ? Digital-GlobalSoft1
How to add 'ASPNET.mdf' file into server explorer in visual studio 2005?  2
If you are using components in your application, how can you handle exceptions raised in a component ? Accenture3
What are the methods in Thread class?  1
How the framework differentiate between 2 version dlls? eg Version 2.0 and 2.1 dlls are there. both are referred in the code.but we are using only name of that dll not the version number. in run time how the framework know which dll has to be referred? Deloitte1
What is the common property in .net? Nth-Solution1
What is reflection? Merrill-Lynch3
Can source code be reverse-engineered from IL?  2
Can you draw and explain the .NET Farmework? Bosch2
Can u tell me differences which are introduced in .Net 1.1 and 2.0 and 3.0 and also in 3.5 ? by detailed? ABC1
 
For more Dot Net Framework 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