Constants
Constants
Constants
- Constant members are the one whose value is remains same at all the
time.
- Constant members are implicitly static members, so they cannot use ‘static’
keyword explicitly to access. So, they can be accessed as same as static
variables in programs.
Code Samples
using System;
public consandreadonly()
{
HoursperDay = 23;
}
# Note: This code will generate following compilation error , because constant
members are implicitly static members.
(6). Accessing Constant members outside the class in which they are
declared