C
codefragment
Hi
The methods below are identical except they take as arguments
different enum types.
There must be a better way of writing this?
ta
public string ConcatValues(params EnumType1 [] types)
{
StringBuilder sb = new StringBuilder();
bool first = true;
foreach (EnumType1 type in types)
{
if (first)
{
first = false;
}
else
{
sb.Append(",");
}
sb.Append((int)type);
}
return sb.ToString();
}
public string ConcatValues(params EnumType2 [] types)
{
StringBuilder sb = new StringBuilder();
bool first = true;
foreach (EnumType2 type in types)
{
if (first)
{
first = false;
}
else
{
sb.Append(",");
}
sb.Append((int)type);
}
return sb.ToString();
}
etc
The methods below are identical except they take as arguments
different enum types.
There must be a better way of writing this?
ta
public string ConcatValues(params EnumType1 [] types)
{
StringBuilder sb = new StringBuilder();
bool first = true;
foreach (EnumType1 type in types)
{
if (first)
{
first = false;
}
else
{
sb.Append(",");
}
sb.Append((int)type);
}
return sb.ToString();
}
public string ConcatValues(params EnumType2 [] types)
{
StringBuilder sb = new StringBuilder();
bool first = true;
foreach (EnumType2 type in types)
{
if (first)
{
first = false;
}
else
{
sb.Append(",");
}
sb.Append((int)type);
}
return sb.ToString();
}
etc