Linked Questions

18 votes
3 answers
13k views

Possible Duplicate: Is it better to call ToList() or ToArray() in LINQ queries? I have code like this: void Foobar(string[] arr, Dictionary<string, string[]>) { var t = arr.Intersect(dic....
abatishchev's user avatar
17 votes
3 answers
10k views

Background: I admit I did not attempt to benchmark this, but I'm curious... What are the CPU/memory characteristics of the Enumerable.ToArray<T> (and its cousin Enumerable.ToList<T>)? ...
Branko Dimitrijevic's user avatar
0 votes
2 answers
499 views

Possible Duplicate: Is it better to call ToList() or ToArray() in LINQ queries? Hi, I have following code static void Main(string[] args) { const string FileName = @"c:\words"...
manu's user avatar
  • 1,837
90 votes
5 answers
40k views

As a new .NET 3.5 programmer, I started to learn LINQ and I found something pretty basic that I haven't noticed before: The book claims every array implements IEnumerable<T> (obviously, ...
ET.'s user avatar
  • 1,959
70 votes
6 answers
21k views

Consider this code: var query = db.Table .Where(t => SomeCondition(t)) .AsEnumerable(); int recordCount = query.Count(); int totalSomeNumber = query.Sum(); decimal ...
Ocelot20's user avatar
  • 10.8k
52 votes
9 answers
25k views

So I've got a collection of structs (it's actually a WCF datacontract but I'm presuming this has no bearing here). List<OptionalExtra> OptionalExtras; OptionalExtra is a struct. public partial ...
Liam's user avatar
  • 30k
28 votes
6 answers
23k views

Can someone tell me which one is more efficient between List<int> and int[]. Because I am working on a project and as you might know efficiency is way so important concern now. If you added ...
Tarik's user avatar
  • 82.2k
34 votes
7 answers
48k views

I'm using .Net 3.5 (C#) and I've heard the performance of C# List<T>.ToArray is "bad", since it memory copies for all elements to form a new array. Is that true?
George2's user avatar
  • 46k
26 votes
5 answers
63k views

This is easy for me to perform in TSQL, but I'm just sitting here banging my head against the desk trying to get it to work in EF4! I have a table, lets call it TestData. It has fields, say: ...
Phil Figgins's user avatar
23 votes
3 answers
22k views

I have two collections of strings: CollectionA is a StringCollection property of an object stored in the system, while CollectionB is a List generated at runtime. CollectionA needs to be updated to ...
Grace Note's user avatar
  • 3,215
37 votes
1 answer
3k views

In .NET<5 and .NET Core 3.1 the following code var d = new Dictionary<string, int> { { "a", 0 }, { "b", 0 }, { "c", 0 } }; foreach (var k in d.Keys) { d[k]+=...
tmaj's user avatar
  • 35.9k
10 votes
4 answers
2k views

I have 2 int arrays. int[] data1 # int[] data2 # I want to create a 3rd int[] data3 which is the differences between the 2 other arrays. Let us take the 1st value in data1. The value is 15 (e.g.). ...
Andrew Simpson's user avatar
7 votes
3 answers
5k views

Since you need to input the length of an array at the time of creation, I assume that it requires a solid, continuous block of memory. A List can be dynamically expanded, so does this mean that it ...
Aeon2058's user avatar
  • 547
1 vote
2 answers
2k views

I'm constructing a simple search function for a site. The aim is to allow the user to find 'swimmers' and add them to a list via a search box, using a query like "bob staff". The first part of this I ...
HennyH's user avatar
  • 7,984
0 votes
3 answers
1k views

I am new with linq, I need to split an IEnumerable of a type Couple(string text, bool indicator) to multiple IEnumerables based on the indicator, I tried with skipWhile and TakeWhile but I didn't find ...
SaliaMun's user avatar

15 30 50 per page