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

C#

 
AnswerRe: Read from Byte Array Pin
Mario Majčica28-Jun-11 0:31
professionalMario Majčica28-Jun-11 0:31 
AnswerRe: Read from Byte Array Pin
BobJanova28-Jun-11 0:52
MemberBobJanova28-Jun-11 0:52 
GeneralBitConverter Endianness Pin
dybs28-Jun-11 13:56
Memberdybs28-Jun-11 13:56 
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 
I store two kinds of data types (Bar1 and Bar2) in the same dictionary. Both data types dervies from Foo class. I would like to extract only the Bar2 elements from the dictionary.

Here is what I got:
abstract class Foo
{
}

class Bar1 : Foo
{
}

class Bar2 : Foo
{
}

class Program
{
    static void Main(string[] args)
    {
        Dictionary<string, Foo> foos = new Dictionary<string, Foo>();
        for(int i = 0; i < 5; i++)
           foos.Add("Bar1." + i, new Bar1());

        for (int i = 0; i < 10; i++)
           foos.Add("Bar2." + i, new Bar2());

        List<Bar2> bar2List = new List<Bar2>();
        foreach (Foo foo in foos.Values)
        {
            if(foo is Bar2)
            {
                bar2List.Add((Bar2)foo);
            }
        }
    }
}


Are there any other method to extract the Bar2 elements from the dictionary into the Bar2 array (bar2List) instead of using foreach-loop and if-statment?
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 
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 

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.