Click here to Skip to main content
15,891,014 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# SQL SELECT query taking too long Pin
Mycroft Holmes5-Jul-13 14:03
professionalMycroft Holmes5-Jul-13 14:03 
QuestionI am geting an error about callbackOnCollectedDelegate Pin
mahua225-Jul-13 2:11
mahua225-Jul-13 2:11 
AnswerRe: I am geting an error about callbackOnCollectedDelegate Pin
Ron Beyer5-Jul-13 3:40
professionalRon Beyer5-Jul-13 3:40 
AnswerRe: I am geting an error about callbackOnCollectedDelegate Pin
Alan N5-Jul-13 3:48
Alan N5-Jul-13 3:48 
GeneralRe: I am geting an error about callbackOnCollectedDelegate Pin
Ron Beyer5-Jul-13 4:44
professionalRon Beyer5-Jul-13 4:44 
QuestionDifference between {list}.First() and {list}[0] Pin
velvet75-Jul-13 0:59
velvet75-Jul-13 0:59 
AnswerRe: Difference between {list}.First() and {list}[0] Pin
Marco Bertschi5-Jul-13 1:18
protectorMarco Bertschi5-Jul-13 1:18 
AnswerRe: Difference between {list}.First() and {list}[0] Pin
Nicholas Marty5-Jul-13 1:24
professionalNicholas Marty5-Jul-13 1:24 
if you can call
C#
var item = list[0]

it's probably faster than calling
C#
var item = list.First()


This is the code of the First Extension

C#
public static TSource First<TSource>(this IEnumerable<TSource> source) { 
   if (source == null) throw Error.ArgumentNull("source");
   IList<TSource> list = source as IList<TSource>;
   if (list != null) {
      if (list.Count > 0) return list[0]; 
   }
   else { 
      using (IEnumerator<TSource> e = source.GetEnumerator()) { 
         if (e.MoveNext()) return e.Current;
      } 
   }
   throw Error.NoElements();
}


The First method is a LINQ-Extension and is used for IEnumerable. Not all IEnumberable implementations do support the direct access of elements through an index (As IEnumberable does not have a method implemented for it).

IEnumberable gets implemented by nearly all of the .NET Collections, Lists or Arrays. So you don't have to care if you can access it directly with the index or not.
AnswerRe: Difference between {list}.First() and {list}[0] Pin
Pete O'Hanlon5-Jul-13 3:19
mvePete O'Hanlon5-Jul-13 3:19 
AnswerRe: Difference between {list}.First() and {list}[0] Pin
Abhinav S6-Jul-13 1:41
Abhinav S6-Jul-13 1:41 
Questionunable to insert data Pin
new to c# programming4-Jul-13 21:49
new to c# programming4-Jul-13 21:49 
AnswerRe: unable to insert data Pin
Pete O'Hanlon4-Jul-13 21:58
mvePete O'Hanlon4-Jul-13 21:58 
GeneralRe: unable to insert data Pin
new to c# programming4-Jul-13 22:48
new to c# programming4-Jul-13 22:48 
AnswerRe: unable to insert data Pin
Simon_Whale4-Jul-13 22:02
Simon_Whale4-Jul-13 22:02 
GeneralRe: unable to insert data Pin
new to c# programming4-Jul-13 22:49
new to c# programming4-Jul-13 22:49 
QuestionC# shuffle one column out of two Pin
yandroide4-Jul-13 10:14
yandroide4-Jul-13 10:14 
AnswerRe: C# shuffle one column out of two Pin
Eddy Vluggen4-Jul-13 10:21
professionalEddy Vluggen4-Jul-13 10:21 
AnswerRe: C# shuffle one column out of two Pin
thanh_bkhn4-Jul-13 19:03
professionalthanh_bkhn4-Jul-13 19:03 
QuestionSplit string in multiple strings Pin
Sachin k Rajput 4-Jul-13 1:46
Sachin k Rajput 4-Jul-13 1:46 
AnswerRe: Split string in multiple strings PinPopular
Richard Deeming4-Jul-13 2:48
mveRichard Deeming4-Jul-13 2:48 
QuestionHow to use “Client Application Services” in Windows Forms Applications even in offline / disconnected mode Pin
devenv.exe3-Jul-13 23:21
professionaldevenv.exe3-Jul-13 23:21 
AnswerRe: How to use “Client Application Services” in Windows Forms Applications even in offline / disconnected mode Pin
Eddy Vluggen4-Jul-13 0:28
professionalEddy Vluggen4-Jul-13 0:28 
GeneralRe: How to use “Client Application Services” in Windows Forms Applications even in offline / disconnected mode Pin
devenv.exe4-Jul-13 1:10
professionaldevenv.exe4-Jul-13 1:10 
GeneralRe: How to use “Client Application Services” in Windows Forms Applications even in offline / disconnected mode Pin
Eddy Vluggen4-Jul-13 2:48
professionalEddy Vluggen4-Jul-13 2:48 
Questionexecute query Pin
new to c# programming3-Jul-13 20:25
new to c# programming3-Jul-13 20:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.