Questions tagged [convertall]
13 questions
13
votes
4 answers
Converting a list of ints to a byte array
I tried to use the List.ConvertAll method and failed. What I am trying to do is convert a List to byte[]
I copped out and went this route, but I need to figure out the ConvertAll method...
List integers...
internal byte[]…

MQS
- 413
- 2
- 6
- 18
10
votes
4 answers
C# List .ConvertAll Efficiency and overhead
I recently learned about List's .ConvertAll extension. I used it a couple times in code today at work to convert a large list of my objects to a list of some other object. It seems to work really well. However I'm unsure how efficient or fast this…

mBrice1024
- 790
- 5
- 25
3
votes
3 answers
C# merge two lists into one list like Enumerable.ConvertAll
I want to convert two lists with the same index into a single list.
Given this:
List ListA = new List { 1, 2, 3, 4, 5 };
List ListB = new List { "A","B","C","D","E" };
until now, I used this:
List…

jyje
- 45
- 6
3
votes
4 answers
why does C# convertall require 2 parameters
I have an array of Car objects
I want to conver them to a list of Vehicle objects
I thought this would work
Vehicle[] vehicles = cars.ConvertAll(car=> ConvertToVehicle(car)).ToArray();
but its complaining that ConvertAll requires two…

leora
- 188,729
- 360
- 878
- 1,366
2
votes
1 answer
Converter And ConvertAll alternative for UWP C#
I am creating an app in UWP and actually noticed that the System.Converter and Array.ConvertAll functions doesn't exist in there... Why ? :/
Is there any way I could get them ?

Ahmad45123
- 402
- 1
- 4
- 15
1
vote
0 answers
visual studio 2017 debugger does not show variables when C# Array.ConvertAll is used
When I use C# Array.ConvertAll, the variable in the body of the converter function is not visible any more in the debugger in Visual Studio 2017.
For example in:
public static void Test()
{
Vector3[] OriginalArray = new Vector3 [3]{ new…

isgoed
- 724
- 6
- 12
1
vote
2 answers
Powershell - How-to use $List.convertAll() or alternate C# method to clone a list
Suppose I have a list:
$DeletedUsers = New-Object System.Collections.Generic.List[System.object]
So I can easily add and remove users from the collection.
I want to be able to pass this list to a function that does something, but without modifying…

Phatmandrake
- 187
- 3
- 15
1
vote
3 answers
Method chaining generic list extensions
I have a List of a "complex" type - an object with a few string properties. The List itself is a property of another object and contains objects of a variety of types, as shown in this abbreviated class structure:
Customer {
public…

cori
- 8,666
- 7
- 45
- 81
1
vote
1 answer
C# - generic List and ConvertAll() Method, how does it internally work?
from some code I found in Sacha Barbers free mvvm framework chinch I saw this:
return new DispatcherNotifiedObservableCollection(
DataAccess.DataService.FetchAllOrders(
…

msfanboy
- 5,273
- 13
- 69
- 120
1
vote
2 answers
Exposing a List via an IList
I have a private member of type List where the T are rich domain objects. The domain in my application contains many methods that expect a T.
I want to expose only a public property of type IList where T : IT. IT has a small footprint which…

Stefan de Kok
- 2,018
- 2
- 15
- 19
0
votes
1 answer
Using Linq ConvertAll to create a backup of a list before altering the list
I'm working on a project where I have a list of objects with a nested list of which I want to make a backup before I update the original list.
I'm close but I'm having trouble finding the correct syntax so I hope you can help me out here.
This is…

Cainnech
- 439
- 1
- 5
- 17
0
votes
2 answers
How do I convert a string array to a byte array using Array ConvertAll?
I can convert string[] to byte[] like in the following code:
byte[] k = {255, 150, 155, 255, 255, 255, 255, 255, 255, 255, 55, 55, 15, 55, 155, 55};
string st = BitConverter.ToString(Array.ConvertAll(k, Convert.ToByte));
byte[] kk = new…

IshiRaj Inam
- 15
- 4
0
votes
2 answers
C# ConvertAll syntax
I'm trying to understand the syntax for ConvertAll in C#, and despite looking at several examples and trying to copy them, I can't get the following line containing s2 to compile; VSE2013 says
"Error 1 No overload for method 'ConvertAll'…

user3150422
- 67
- 1
- 4