Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help - what is Constants in .NET
Blog
 
# Wednesday, December 02, 2009

constant is a variable whose value cannot be changed throughout its lifetime:

const int abc = 5; // This value cannot be changed

Constants have the following characteristics:

  1. They must be initialized when they are declared, and once a value has been assigned, it can never be overwritten.
  2. The value of a constant must be computable at compile time. Therefore, we can’t initialize a constant with a value taken from a variable. If you need to do this, you will need to use a readonly field.
  3. Constants are always implicitly static. However, notice that we don’t have to include the static modifier in the constant declaration.
Wednesday, December 02, 2009 9:14:20 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .Net  | 
Copyright © 2010 SoftwareCodeHelp. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: