Rational Dev

C#: Constant String From a Constant Char

Have you ever wanted to use a char as a constant string and tried something similar to below, but can't because const string must be valid at compile time?

const string AcceptCommand = Keys.Enter.ToString();

The closest I have found on how to do this is:

private static readonly AcceptCommand = Keys.Enter.ToString();

Posted On: May 19, 2009 - 1:17pm by Rational
( categories: )

User login

Google

Navigation