有没有办法将 3D 数组 String[3,7,x] 转换为 csv?
我有一个字符串数组.. myArr[3,7,x].. 该数组保存用户输入,在传递给我的存储过程之前,我想将第三维中的值转换为 csv.. 例如,如果 x=2且 [3,7,0]=1 且 [3,7,1]=2 且 [3,7,2]=3 则 csv 将为 1,2,3。
我认为使用 String.Join(",",myArr[3,7].something..) 有一种简单的方法可以做到这一点,
不确定这是否可能或如何做到这一点。我尝试的另一个选项是通用列表(http://stackoverflow.com/questions/1890093/converting-a-generic-list-to-a-csv-string),但这需要Linq(?)并且我们在.Net2上。
有什么想法吗?可以编写我自己的自定义函数来执行此操作,但只是想知道框架内是否有任何内容允许我执行此操作。任何帮助表示赞赏。
干杯
I have a String array.. myArr[3,7,x].. The array holds user input and before passing to my stored proc I would like to convert the values in the 3rd dimension to csv.. For eg if x=2 and [3,7,0]=1 and [3,7,1]=2 and [3,7,2]=3 then the csv would be 1,2,3.
I thought there would be an easy way to do this using String.Join(",",myArr[3,7].something..)
Not sure if this is possible or whats the way to do it. The other option I tried was generic list (http://stackoverflow.com/questions/1890093/converting-a-generic-list-to-a-csv-string) but that requires Linq(?) and we are on .Net2.
Any ideas? Can write my own custom function to do this but just wondering if there is anything within the framework that allows me to do this. Any help is appreciated.
cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,没有内置方法可以通过这种方式获取阵列的横截面。只需创建一个数组并在循环中复制值:
No, there is no built in way to get a cross section of an array that way. Simply create an array and copy the values in a loop: