Advertisement

06.24.2008 at 03:43PM PDT, ID: 23512920
[x]
Attachment Details

how to convert a list into a an array?

Asked by vielkacarolina1239 in C# Programming Language, .Net Editors & IDEs, Visual Studio .NET 2005

Tags: microsoft, visual studio 2005, cannot convert from 'System.Collections.Generic.List' to 'myObj[]'

Hi,

I am using C# in visual studio 2005

How can I convert a list into an array in c#. I now that vb allows you to convert a list into an array.

void myFunc()
{

List<myObj> myList = new List<myObj>

//Asumen that I have created myObj1, myObj2, myObj3 and I add these objects to the list.
myList.Add(myObj1);
myList.Add(myObj2);
myList.Add(myObj3);

//I need to call this method and convert _myList into an array because the method is expending an array
//not a List<T>. In Visual Basic, I can convert a list into an array, example, method1(_myList.ToArray)
//I need to do this because I am calling a webservice from another company and the the proxy contains
// this method.
 method1(_myList ) ;
}

void method1(myObjmy myArr[])
{
//do something
}


Please, look at the error that I am getting in the error section

Start Free Trial
[+][-]06.24.2008 at 03:47PM PDT, ID: 21861294

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, .Net Editors & IDEs, Visual Studio .NET 2005
Tags: microsoft, visual studio 2005, cannot convert from 'System.Collections.Generic.List<myObj>' to 'myObj[]'
Sign Up Now!
Solution Provided By: gregoryyoung
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628