I have the following:
var options = xxx
.Select(x => new SelectListItem
{
Value = ((int) Enum.ToObject(t, x)).ToString(),
Text = Regex.Replace(x.ToString(), "([A-Z])", " $1").Trim()
});
This is part of a method that’s called like this:
GetSpacedOptions(bool zeroPad = false)
How can I make it so if the zeroPad is set to true then instead of returning 1,2,3,4,5 etc that it returns “01”,”02″ etc as the value in the select? If zeroPad is set to default or false then it needs to return 1,2 etc.
I’m not sure I got the question right but here is one way to do it.