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

147 questions
1
vote
1 answer

Are there any other methods to convert Span Bytes into a Convertable base64?

Span MySpan = stackalloc byte[] { 12, 21, 32 }; MessageBox.Show(Convert.ToBase64String(MySpan.ToArray())); This block of code is the method I tried with success, but ToArray allocates memory, for this I want to find a way to be able to…
1
vote
1 answer

Java Generics: Stream toArray()

Given a simple generic class: private static class Container { private List aList; private T aValue; private Container(List aList, T aValue) { this.aList = aList; this.aValue = aValue; } } Initialize a list…
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
  • 967
  • 2
  • 16
  • 30
1
vote
0 answers

REACTJS - GSAP "toArray" function doesn't work well with dynamic tagging

I'm trying to do a simple animation where every word of one paragraph appears one after the other but I'm struggling with gsap.utils.toArray function. I'm first using a small js function to separate every words of a paragraph into unique divs : …
1
vote
2 answers

Using a List to Fetch Columns from a DataTable

I can fetch columns x1, x2, and x3 from a DataTable (DT) successfully, using e.g. Dim arrayOfObjects()() As Object = DT.AsEnumerable().Select(Function(b) {b("x1"), b("x2"), b("x3")}).ToArray() However, most of my fetching will involve different…
user15535192
1
vote
1 answer

Making Select and ToArray for DataTable DBNull-aware

The exception "Object cannot be cast from DBNull to other types" is being thrown when pulling data from a DataTable. Obviously the syntax below is not "DBNull aware." Is there a way to prevent this exception from being thrown if a DBNull is found…
user15535192
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
  • 65
  • 1
  • 12
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,279
  • 7
  • 44
  • 74
1
vote
2 answers

toArray() returns object[]

I am trying to convert an ArrayList to an Array using toArray(), but it returns an object[] instead of double[]. See below: double [] arr = arrList.toArray(new Double[arrList.size()]); I'm getting an Incompatible Types error. This is what the…
pizza
  • 35
  • 6
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
  • 6
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
  • 1,035
  • 13
  • 19
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…
user6893697
  • 21
  • 1
  • 2