铸造对象的整个数组到字符串 [英] Casting entire array of objects to string

查看:135
本文介绍了铸造对象的整个数组到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我型对象这是一个字符串数组。我想将它们转换为字符串。什么是这样做的最快方法是什么?

I have an array of type object which are strings. I would like to convert them to strings. What would be the quickest way of doing so?

例如:我有这样的 [对象] 键,要转换它,所以它是这样的的String []

Eg.: I have this object[] and want to convert it so it is this string[].

更新:我认为这个问题是,一些物体上的 [对象] 实际上是其它对象,比如整数。我需要他们先转换为字符串。请包括到您的解决方案。谢谢你。

UPDATE: I think the problem is that some of the objects on the object[] are actually other objects like integers. I would need to convert them to strings first. Please include that into your solution. Thanks.

推荐答案

可能不是最有效的方式来做到这一点...它的时候对象不一定是字符串工作的好处。

Probably not the most efficient way to do it...it has the benefit of working when the objects aren't necessarily strings.

string[] output = (from o in objectArray
                   select o.ToString()).ToArray()

这篇关于铸造对象的整个数组到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆