IEnumerable to string

前端 未结 7 2152
既然无缘
既然无缘 2021-02-04 23:55

I have a DataTable that returns

IDs
,1
,2
,3
,4
,5
,100
,101

I want to convert this to single string value, i.e:

,1,2,3,4,5,100         


        
7条回答
  •  鱼传尺愫
    2021-02-05 00:33

    I had a similar issue with general Array type and i solved it as follows

    string GetMembersAsString(Array array)
    {
        return string.Join(",", array.OfType());
    }
    
    
    

    Note that call OfType() is mandatory.

    提交回复
    热议问题