Switch case and generics checking

后端 未结 7 760
情话喂你
情话喂你 2021-01-01 10:36

I want to write a function that format int and decimal differently into string

I have this code:

and I want to rewrite it to generi

7条回答
  •  甜味超标
    2021-01-01 11:15

    Alternatively you could always do:

    public static string FormatWithCommaSeparator(T[] items)
    {
        var itemArray = items.Select(i => i.ToString());
    
        return string.Join(", ", itemArray);
    }
    

提交回复
热议问题