When MultiVal is null, I want it to be replaced by a space " ", how can I do it?
var selectedComponents=string.Join(',', MultiVal);
sb.Replace("{components}",selectedComponents);
When MultiVal is null, I want it to be replaced by a space " ", how can I do it?
var selectedComponents=string.Join(',', MultiVal);
sb.Replace("{components}",selectedComponents);
If I understood correctly
var selectedComponents = MultiVal == null ? " " : string.Join(',', MultiVal);
sb.Replace("{components}", selectedComponents);
You could do something like:
var selectedComponents = string.Join(',', MultiVal ?? "");
sb.Replace("{components}",selectedComponents);
Hope you are looking for something like this. If MultiVal is not null you can place another string where it says string.Empty:
var selectedComponents = string.Join(",", MultiVal == null? " " : string.Empty);
Or you can just simply check if MultiVal is null:
if (MultiVal == null)
{
selectedComponents = string.Join(",", " ");
}