Readonly vs. const?

Answer Posted / pavan

both of them does the same work these value cannot be
changed
but with a samll difference
using const we can assign a value before compile time
but using readonly we can assign value to the varible ones
in runtime

Is This Answer Correct ?    14 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the default security setting in .net?

527


Explain what is a delegate?

578


What is typical about a windows process in regards to memory allocation in .net?

548


What is a formatter in .net?

572


What is the difference between asp.net and asp?

590






How to implement getcommon method in class a? Are you seeing any problem in the implementation?

619


What is the difference between constants and read-only variables?

539


What is interface and abstract class in .net?

550


What is the new three features of COM+ services, which are not there in COM (MTS)

1533


Is .net core installed?

519


Describe the difference between inline and code behind which is best in a loosely coupled solution?

2116


Do you know what is lambda expressions in c#?

544


I am constantly writing the drawing procedures with system.drawing.graphics, but having to use the try and dispose blocks is too time-consuming with graphicsobjects. Can I automate this?

530


Explain the difference between managed and unmanaged code?

452


How do you instantiate a complex number?

586