【转】c#怎样将object[]转换为string[]?


object[] objs = new object[] { "1", "2", "3" };
string[] strs = new string[objs.Length];
objs.CopyTo(strs, 0);

当然必须确保你的object每个对象都是字符串。
如果object数组中有多种对象类型如下:
object[] objs = new object[] { "1", 1, 2.3 }; 那另当别论了。
for(int i=0;i<objs.Length;i++)
{
strs[i] = objs[i].ToString();
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。