I have a set of constant strings which are related to each other:
private const string tabLevel1 = "\t";
private const string tabLevel2 = "\t\t";
private const string tabLevel3 = "\t\t\t";
...
I'm looking for a more elegant way to declare these, something like:
private const string tabLevel1 = "\t";
private const string tabLevel2 = REPEAT_STRING(tabLevel1, 2);
private const string tabLevel3 = REPEAT_STRING(tabLevel1, 3);
...
Is there some preprocessor directive or some other way of achieving this?
P.S.
I already know that const string tabLevel2 = tabLevel1 + tabLevel1;
workes, probably due to this. I'm looking for the general case for arbitrary n
.
EDIT
I wish to clarify why I need const
and not static readonly
: The constants are used as parameters to a property decorator, e.g. [GridCategory(tabLevel2)]
, and must be known at compile time.