What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 12854 |  Welcome, Guest!   Register  Login
 Home > Forums > Ask Interview Questions > explain difference between constant & read only in C# ...
Sekar.C

explain difference between constant & read only in C#

Replies: 8 | Posted by: Sekar.C on 4/23/2012 | Category: Ask Interview Questions Forums | Views: 1529 | Status: [Member] | Points: 10  


Hi,
explain difference between constant & read only in C# own words
Regards
sekar.c

Regards
Sekar.c


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Dotnetrajanikanth
Dotnetrajanikanth  
Posted on: 4/23/2012 7:40:34 AM
Level: Starter | Status: [Member] | Points: 25

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Santhiram
Santhiram  
Posted on: 4/23/2012 1:36:10 PM
Level: Starter | Status: [Member] | Points: 25

Readonly fields can be initialized at compile time & runtime also where as const members can be initialized only at compile time.

Thanks
Shanti

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 4/23/2012 9:04:38 PM
Level: Silver | Status: [Member] | Points: 25

Constant variable once assigned can't be changed, but ReadOnly variable can be changed on the fly.


Regards,
Singaravel M

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 4/23/2012 9:05:11 PM
Level: Silver | Status: [Member] | Points: 25

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Savariya
Savariya  
Posted on: 4/24/2012 2:02:29 AM
Level: Starter | Status: [Member] | Points: 25

Main Difference between Constant and readonly is that
At the time of declaration you MUST have to define some value for constant variable where as for readonly variable you can definne its value Later(Only in constructor) also


ThANKS

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sandeepmhatre
Sandeepmhatre  
Posted on: 3/23/2013 8:43:11 AM
Level: Starter | Status: [Member] | Points: 25

Refer this link

http://sandeepmhatre.blogspot.com/2013/03/constants-and-read-only.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Jayakumars
Jayakumars  
Posted on: 3/23/2013 9:22:00 AM
Level: Bronze | Status: [Member] | Points: 25

hi

refer this
http://www.aspdotnet-suresh.com/2012/10/cnet-what-is-difference-between-const.html

Mark as Answer if its helpful to you

Regards
Email Id: kumaraspcode2009@gmail.com

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

VINI1985
VINI1985  
Posted on: 3/28/2013 1:27:19 AM
Level: Starter | Status: [Member] | Points: 25

Whenever declare Constant variable it is mandatory to initialize as well
one more thing with constant can not be static.

Whenever declare readonly variable it is not mandatory to initialize as well
one more thing with constant can be static.

Sekar.C, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 3:28:11 AM