本文介绍了如何将System.Object [*]转换为System.Object []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当我试图返回一个 Array 在VFP9语言COM / DLL到我的.NET C#项目我收到一个系统。对象[*] 数组,我不能转换为 System.Object [] (没有星号)。解决方案 Timwi的解决方案应该可以正常工作。你可以使用Linq做一些简单的事情: object [] newArray = sourceArray.Cast< object>()。ToArray ); 如果您需要重新创建 System.Object [*] code>将其传回VFP,您可以使用此重载> c> c> c> CreateInstance( Type elementType, int [] lengths, int [] lowerBounds ) 您可以使用它如下: object [] normalArray = ... //创建下边界为1的数组数组arrayStartingAt1 = Array.CreateInstance( typeof(object), new [] {normalArray。 Length}, new [] {1}); Array.Copy(normalArray,0,arrayStartingAt1,1,normalArray.Length); When I Tried to return an Array in VFP9 language COM/DLL to my .NET C# projectI receive a System.Object[*] array and I can not cast to System.Object[] (Without asterisk). 解决方案 Timwi's solution should work fine. You can do something a bit simpler using Linq:object[] newArray = sourceArray.Cast<object>().ToArray();In case you need to recreate a System.Object[*] to pass it back to VFP, you can use this overload of the Array.CreateInstance method:public static Array CreateInstance( Type elementType, int[] lengths, int[] lowerBounds)You can use it as follows:object[] normalArray = ...// create array with lower bound of 1Array arrayStartingAt1 = Array.CreateInstance( typeof(object), new[] { normalArray.Length }, new[] { 1 });Array.Copy(normalArray, 0, arrayStartingAt1, 1, normalArray.Length); 这篇关于如何将System.Object [*]转换为System.Object []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 22:15