Questions tagged [toarray]

toarray, to convert from arraylist to array this method can be used. Being language specific for e.g. in Java its its available with ArrayList and in C# its used with List. Use this tag for toarray related questions.

toArray() Returns an array containing all of the elements in this list in the correct order.

Resource

136 questions
1
vote
1 answer

Why does not WhereSelectArrayIterator implement ICollection?

In looking at System.Linq.Enumerable through Reflector i noticed that default iterator used for Select and Where extension methods - WhereSelectArrayIterator - does not implement ICollection interface. If i read code properly this causes some other…
1
vote
1 answer

Doctrine 2 toArray() method until we have traits?

I really need a way to cast my entity to an Array. I know can do it manually but doing to on each entity is painfull, more working with relationship will not be easy. How do you do? Have you implemented anything like that?
JohnT
  • 947
  • 2
  • 16
  • 30
1
vote
2 answers

How to print a specific String stored into an array of String into an ArrayList of Strings Arrays?

so, as per the question, I have this code in Java: public class example { static ArrayList test = new ArrayList(); private String[] a = {"this", "is,", "a test"}; private String[] b = {"Look", "a three-headed",…
Agricolo
  • 53
  • 8
1
vote
2 answers

Converting array of Objects to array of custom Types

I have a method to build the array for the required type. It works for the primitive types. But when I have array of custom objects it doesn't work. So I have tweaked it. But still it fails. Code is like this : private Object buildArray( …
java_enthu
  • 2,099
  • 7
  • 39
  • 66
1
vote
3 answers

What does "new Boolean[0]" or "new String[0]" in Java evaluate to

What does new Boolean[0] or new String[0] in Java evaluate to? Why do we need a number here ? Which of the following is proper way? myList.toArray(new Boolean[0]) or myList.toArray(new Boolean[myList.size()])
philjack
  • 89
  • 5
1
vote
2 answers

EnumMap T[] toArray(T[] a) implementation

I found that EnumMap T[] toArray(T[] var2) have this implementation: public T[] toArray(T[] var1) { int var2 = this.size(); if (var1.length < var2) { var1 = (Object[])((Object[])Array.newInstance(var1.getClass().getComponentType(),…
Yury Finchenko
  • 917
  • 11
  • 16
1
vote
0 answers

Pool Destroyed while using collection.aggregate().toArray()

When I try to get the result of Aggregation, I will get an Pool Destroyed error. A similar question in How to solve MongoError: pool destroyed while connecting to CosmosDB but first I don't set replicaSet and second the fix for microsoft doesn't…
1
vote
1 answer

C# Class select multiple fields in Xamarin

I want to select multiple fields from a list. This is my code: string[] NamesArray = Users .Select(i => new { i.FirstName, i.LastName }) .Distinct() .OrderByDescending(i => i.FirstName) …
user9198450
1
vote
6 answers

Java: How can I read and store them in array by a new line in ArrayList?

Here is what my .txt file looks like (but more than 100 elements per line and more than 100 lines): -0.89094 -0.86099 -0.82438 -0.78214 -0.73573 -0.68691 -0.63754 -0.42469 -0.3924 -0.36389 -0.33906 -0.31795 -0.30056…
1
vote
0 answers

find().toArray() doesn't return anything

I'm quite new to mongodb and I'm having some issues I cannot find answers to. My question is performance I suppose. When I'm trying to query a collection using db.collection.find() I can get all the result and look through them in robomongo. What I…
1
vote
1 answer

Trouble using ExcelRange.ToArray<>() in EPPlus

I am using EPPlus and don't seem to be able to get the ToArray<> method to work. I am trying to pull out an array of string variables of column headers in a worksheet. My code... public static string[] GetWshHeaders(string WbkNm) { …
1
vote
0 answers

Converting Arraylist to an Array

I need help trying to convert an arraylist to an array. I am having trouble doing so, If anyone can show me where to implement the (.toarray) piece of code. public class BFFHelper { ArrayList myBFFs; Scanner keyboard = new…
1
vote
0 answers

Using OrderBy and ToArray to list objects in C# in alphabetical order

I'm working on a web page that displays a list of objects, but they are displayed in a completely random and jumbled up manner. I'm trying to make them show up in alphabetical order. The code I have so far for this is: public ActionResult…
Alycus
  • 221
  • 1
  • 4
  • 14
1
vote
2 answers

populate spinner with String array defined in xml

I'm attempting to create the first page of an app that, after an element from the first spinner is selected, will display a second spinner and populate it with an array based on the selected element of the first spinner. I've found information…
1
vote
3 answers

Transforming an ArrayList to an Array using toArray() method

Consider the following code: import java.util.*; public class ArrayQuestion{ public static void main(String[] args){ List list = new ArrayList<>(); list.add("Chocolate"); …
RamanSB
  • 1,110
  • 7
  • 21