Click here to Skip to main content
15,119,410 members
Home / Discussions / C#
   

C#

 
GeneralRe: BitConverter Endianness Pin
BobJanova28-Jun-11 14:12
MemberBobJanova28-Jun-11 14:12 
GeneralRe: Read from Byte Array Pin
DJ24529-Jun-11 0:57
MemberDJ24529-Jun-11 0:57 
GeneralRe: Read from Byte Array Pin
lukeer29-Jun-11 1:05
Memberlukeer29-Jun-11 1:05 
GeneralRe: Read from Byte Array Pin
DJ24529-Jun-11 1:23
MemberDJ24529-Jun-11 1:23 
QuestionGet one type of elements from dictionary Pin
Mc_Topaz27-Jun-11 4:01
MemberMc_Topaz27-Jun-11 4:01 
AnswerRe: Get one type of elements from dictionary Pin
musefan27-Jun-11 4:08
Membermusefan27-Jun-11 4:08 
GeneralRe: Get one type of elements from dictionary Pin
Mc_Topaz27-Jun-11 4:16
MemberMc_Topaz27-Jun-11 4:16 
GeneralRe: Get one type of elements from dictionary Pin
BobJanova27-Jun-11 4:56
MemberBobJanova27-Jun-11 4:56 
I think
List<Bar2> bar2List = foos.Values.Where(f => f is Bar2).ToList<Bar2>();

... should do it.

Linq-to-objects like this is essentially doing the same thing as the foreach loop in your original suggestion, so performance wise you will gain nothing, but some people will say that the Linqed code is more readable (and in this case I think I'd agree with that).

(Ed: putting the type parameter on Where doesn't work, it tries to cast items before checking them.)
AnswerRe: Get one type of elements from dictionary Pin
Keith Barrow27-Jun-11 4:28
professionalKeith Barrow27-Jun-11 4:28 
GeneralRe: Get one type of elements from dictionary Pin
David198727-Jun-11 5:01
MemberDavid198727-Jun-11 5:01 
AnswerRe: Get one type of elements from dictionary Pin
Ian Shlasko27-Jun-11 10:43
MemberIan Shlasko27-Jun-11 10:43 
AnswerRe: Get one type of elements from dictionary Pin
SledgeHammer0127-Jun-11 12:19
MemberSledgeHammer0127-Jun-11 12:19 
GeneralRe: Get one type of elements from dictionary Pin
PIEBALDconsult27-Jun-11 15:39
professionalPIEBALDconsult27-Jun-11 15:39 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 20:40
professionalMycroft Holmes27-Jun-11 20:40 
GeneralRe: Get one type of elements from dictionary Pin
SledgeHammer0127-Jun-11 20:44
MemberSledgeHammer0127-Jun-11 20:44 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 20:49
professionalMycroft Holmes27-Jun-11 20:49 
QuestionNavigating between forms Pin
Berlus26-Jun-11 2:19
MemberBerlus26-Jun-11 2:19 
AnswerRe: Navigating between forms Pin
Mycroft Holmes26-Jun-11 2:59
professionalMycroft Holmes26-Jun-11 2:59 
AnswerRe: Navigating between forms Pin
Not Active27-Jun-11 3:29
mentorNot Active27-Jun-11 3:29 
QuestionCustom control sometimes doesn't paint/refresh the button on it Pin
teknolog12326-Jun-11 0:13
Memberteknolog12326-Jun-11 0:13 
AnswerRe: Custom control sometimes doesn't paint/refresh the button on it Pin
Dave Kreskowiak27-Jun-11 10:22
mveDave Kreskowiak27-Jun-11 10:22 
QuestionStarting intrupped thread again.. Pin
shivamkalra25-Jun-11 20:06
Membershivamkalra25-Jun-11 20:06 
AnswerRe: Starting intrupped thread again.. Pin
MicroVirus26-Jun-11 1:44
MemberMicroVirus26-Jun-11 1:44 
QuestionNamedPipeClientStream.Connect(int) doesn't throw Exception if Form is closed. [fixed, workaround] Pin
Xmen Real 25-Jun-11 18:59
professional Xmen Real 25-Jun-11 18:59 
QuestionKnow when form loses focus? Pin
Matt U.25-Jun-11 14:30
MemberMatt U.25-Jun-11 14:30 

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.