3
我想對象數組轉換成字符串數組,但不排除空值.. 我得到了下面的代碼對象數組轉換爲字符串array.But它排除空值..轉換對象數組到字符串數組包含空值
string[] foo = myvalues.OfType<object>().Select(o => o.ToString()).ToArray();
我搜索了很多在谷歌,但未能找到解決辦法
請幫助。
編輯: - 得到的答案...
List<string> lst = new List<string>();
foreach (object o in myvalues)
if (o==null)
{
lst.Add(null);
}
else
{
lst.Add(o.ToString());
}
string[] str2 = lst.ToArray();
這個問題是不相關的ASP.NET MVC3。標籤被移除爲非建設性的。 – Hari 2013-02-27 09:11:09