Answer the question
In order to leave comments, you need to log in
How can enum assign regex "any number" (See description)?
public enum Types{
SomeChar = 'D',
Number = ..//нужно чтобы Number соответствовал любому(!) целому/дробному числу
}
Answer the question
In order to leave comments, you need to log in
In enums, only integer values ( byte , sbyte , short , ushort , int , uint , long , and ulong ) or char are allowed .
Alternatively, one of the values of an enumeration element may mean that this value must match any number. But to do this, you need to write code that can correctly interpret such a value.
Instead of enums, you can use constants ( const ) or readonlyvariables. In the latter case, the possibilities for using various data types are not limited, unlike constants. You still have to write the code for verification.
Alexei Nemiro absolutely rightly noted that
In enums, only integer values (byte, sbyte, short, ushort, int, uint, long, and ulong) or char are allowed.
struct STRING_ENUMERATION
{
public const string ENUM_A = "Это строка перечисления";
public const string ENUM_B = "Это другая строка перечисления";
}
class Program
{
static void Main(string[] args)
{
string myVar = STRING_ENUMERATION.ENUM_A;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question