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

C#

 
AnswerRe: Read from Byte Array Pin
Mario Majčica27-Jun-11 23:31
professionalMario Majčica27-Jun-11 23:31 
AnswerRe: Read from Byte Array Pin
BobJanova27-Jun-11 23:52
BobJanova27-Jun-11 23:52 
GeneralBitConverter Endianness Pin
dybs28-Jun-11 12:56
dybs28-Jun-11 12:56 
GeneralRe: BitConverter Endianness Pin
BobJanova28-Jun-11 13:12
BobJanova28-Jun-11 13:12 
GeneralRe: Read from Byte Array Pin
DJ24528-Jun-11 23:57
DJ24528-Jun-11 23:57 
GeneralRe: Read from Byte Array Pin
lukeer29-Jun-11 0:05
lukeer29-Jun-11 0:05 
GeneralRe: Read from Byte Array Pin
DJ24529-Jun-11 0:23
DJ24529-Jun-11 0:23 
QuestionGet one type of elements from dictionary Pin
Mc_Topaz27-Jun-11 3:01
Mc_Topaz27-Jun-11 3: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 3:08
musefan27-Jun-11 3:08 
GeneralRe: Get one type of elements from dictionary Pin
Mc_Topaz27-Jun-11 3:16
Mc_Topaz27-Jun-11 3:16 
GeneralRe: Get one type of elements from dictionary Pin
BobJanova27-Jun-11 3:56
BobJanova27-Jun-11 3:56 
AnswerRe: Get one type of elements from dictionary Pin
Keith Barrow27-Jun-11 3:28
professionalKeith Barrow27-Jun-11 3:28 
GeneralRe: Get one type of elements from dictionary Pin
David198727-Jun-11 4:01
David198727-Jun-11 4:01 
AnswerRe: Get one type of elements from dictionary Pin
Ian Shlasko27-Jun-11 9:43
Ian Shlasko27-Jun-11 9:43 
AnswerRe: Get one type of elements from dictionary Pin
SledgeHammer0127-Jun-11 11:19
SledgeHammer0127-Jun-11 11:19 
GeneralRe: Get one type of elements from dictionary Pin
PIEBALDconsult27-Jun-11 14:39
mvePIEBALDconsult27-Jun-11 14:39 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 19:40
professionalMycroft Holmes27-Jun-11 19:40 
GeneralRe: Get one type of elements from dictionary Pin
SledgeHammer0127-Jun-11 19:44
SledgeHammer0127-Jun-11 19:44 
GeneralRe: Get one type of elements from dictionary Pin
Mycroft Holmes27-Jun-11 19:49
professionalMycroft Holmes27-Jun-11 19:49 
QuestionNavigating between forms Pin
Berlus26-Jun-11 1:19
Berlus26-Jun-11 1:19 
AnswerRe: Navigating between forms Pin
Mycroft Holmes26-Jun-11 1:59
professionalMycroft Holmes26-Jun-11 1:59 
AnswerRe: Navigating between forms Pin
Not Active27-Jun-11 2:29
mentorNot Active27-Jun-11 2:29 
QuestionCustom control sometimes doesn't paint/refresh the button on it Pin
teknolog12325-Jun-11 23:13
teknolog12325-Jun-11 23:13 
AnswerRe: Custom control sometimes doesn't paint/refresh the button on it Pin
Dave Kreskowiak27-Jun-11 9:22
mveDave Kreskowiak27-Jun-11 9:22 
QuestionStarting intrupped thread again.. Pin
shivamkalra25-Jun-11 19:06
shivamkalra25-Jun-11 19: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.