Current .Net Version: 1.1.4322
Home
Articles
Practice C# Online
C# Reference
XML Web Services
RSS Feeds
T-SQL Scripts
Videos
Valuable Links
Contact Us
Mike's C#, VS.NET and SQL Blog
ROR XML Info.
C# Reference
The world's largest C# Language & Framework Class Library Reference Database (second only to Microsoft's)!
Language Reference:
Language Search:
Framework Class Library Reference:
Framework Class Library Search:

constant-expression
Is a:Definition
Applies to Version:C# 1.0 and later
Namespace:N/A
Assembly:N/A (N/A)
Description:An expression that yields a result (value) that can be determined at compile-time.
Example(s):int i = 1; switch (i) { case 1: MessageBox.Show("It's 1."); // 1 is the constant-expression break; case 2: MessageBox.Show("It's 2."); // 2 is the constant-expression break; } public const int num1 = 1 + 100; // (1 + 100) is the constant-experssion public int testnum = 11; public const int num2 = testnum + 100; // oops, can't do that because testnum is a variable, // and its value can't be determined at compile-time // because testnum can change.
 
COPYRIGHT/DISCLAIMER | CONTACT US