Please explain the difference between constants and read-only variables?
Submitted by: MuhammadWhile constants and read-only variable share many similarities, there are some important differences:
☛ Constants are evaluated at compile time, while the read-only variables are evaluated at run time.
☛ Constants support only value-type variables (the only exception being strings), while read-only variables can hold reference-type variables.
☛ Constants should be used when the value is not changing during run time, and read-only variables are used mostly when their actual value is unknown before run time.
☛ Read-only variables can only be initialised at the time of declaration or in a constructor.
Submitted by: Muhammad
☛ Constants are evaluated at compile time, while the read-only variables are evaluated at run time.
☛ Constants support only value-type variables (the only exception being strings), while read-only variables can hold reference-type variables.
☛ Constants should be used when the value is not changing during run time, and read-only variables are used mostly when their actual value is unknown before run time.
☛ Read-only variables can only be initialised at the time of declaration or in a constructor.
Submitted by: Muhammad
Read Online Senior .Net Developer Job Interview Questions And Answers
Top Senior .Net Developer Questions
☺ | Do you know what is Garbage Collector? |
☺ | Do you know what is the difference between an abstract class and an interface? |
☺ | Please tell us what is the difference between Override and Overload in a method? |
☺ | Tell us why do we use the “using” statement? |
☺ | Do you know what is .NET Standard? |
Top Dot Net Technologies Categories
☺ | MSF Interview Questions. |
☺ | .Net Architecture Interview Questions. |
☺ | ASP.Net MVC Interview Questions. |
☺ | Entity Framework Interview Questions. |
☺ | C# (Sharp) Programming Language Interview Questions. |