Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: Iterate over a Collection-Type for its Values using Reflection Pin
BillWoodruff23-Sep-14 2:24
professionalBillWoodruff23-Sep-14 2:24 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 2:37
professionalAgent__00723-Sep-14 2:37 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
BillWoodruff23-Sep-14 4:09
professionalBillWoodruff23-Sep-14 4:09 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 18:41
professionalAgent__00723-Sep-14 18:41 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
BillWoodruff23-Sep-14 20:29
professionalBillWoodruff23-Sep-14 20:29 
SuggestionRe: Iterate over a Collection-Type for its Values using Reflection Pin
George Jonsson23-Sep-14 2:38
professionalGeorge Jonsson23-Sep-14 2:38 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 18:24
professionalAgent__00723-Sep-14 18:24 
AnswerRe: Iterate over a Collection-Type for its Values using Reflection Pin
Simon_Whale23-Sep-14 4:17
Simon_Whale23-Sep-14 4:17 
Hopefully this may be of some use.

C#
List<int>; d = new List<int>() { 1, 2, 3, 4, 5, 6 };
if (typeof(IList).IsAssignableFrom(d.GetType()) == true && d.GetType().IsGenericType == true)
{
    IList x = d;

    //Get the type in the list
    Type t = x.GetType().GetGenericArguments()[0];

    foreach (object item in x)
    {
        switch (t.Name)
        {
            case "Int32":
                int r = (int)item;
                break;
            default:
                break;
        }
    }
}


My only part I wasn't sure of was casting the object back to type that was in the list, So I used a simple switch statement to do the hard work for me. Also apologies for the crap variable naming too.
Every day, thousands of innocent plants are killed by vegetarians.

Help end the violence EAT BACON

GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 18:33
professionalAgent__00723-Sep-14 18:33 
AnswerRe: Iterate over a Collection-Type for its Values using Reflection Pin
Eddy Vluggen23-Sep-14 7:17
professionalEddy Vluggen23-Sep-14 7:17 
GeneralRe: Iterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 18:11
professionalAgent__00723-Sep-14 18:11 
QuestionTCP/IP : Socket programming Pin
Rajeeva B J23-Sep-14 1:10
Rajeeva B J23-Sep-14 1:10 
QuestionRe: TCP/IP : Socket programming Pin
George Jonsson23-Sep-14 1:36
professionalGeorge Jonsson23-Sep-14 1:36 
AnswerRe: TCP/IP : Socket programming Pin
Rajeeva B J23-Sep-14 2:11
Rajeeva B J23-Sep-14 2:11 
SuggestionRe: TCP/IP : Socket programming Pin
George Jonsson23-Sep-14 2:46
professionalGeorge Jonsson23-Sep-14 2:46 
GeneralRe: TCP/IP : Socket programming Pin
Bernhard Hiller23-Sep-14 20:48
Bernhard Hiller23-Sep-14 20:48 
AnswerRe: TCP/IP : Socket programming Pin
Richard MacCutchan23-Sep-14 1:54
mveRichard MacCutchan23-Sep-14 1:54 
QuestionImages are not showing in mail. Pin
demoninside922-Sep-14 21:08
demoninside922-Sep-14 21:08 
QuestionRe: Images are not showing in mail. Pin
Richard MacCutchan22-Sep-14 22:15
mveRichard MacCutchan22-Sep-14 22:15 
AnswerRe: Images are not showing in mail. Pin
demoninside922-Sep-14 22:56
demoninside922-Sep-14 22:56 
GeneralRe: Images are not showing in mail. Pin
Richard MacCutchan22-Sep-14 23:15
mveRichard MacCutchan22-Sep-14 23:15 
AnswerRe: Images are not showing in mail. Pin
Simon_Whale22-Sep-14 22:33
Simon_Whale22-Sep-14 22:33 
AnswerRe: Images are not showing in mail. Pin
Bernhard Hiller23-Sep-14 20:52
Bernhard Hiller23-Sep-14 20:52 
Questionhow to read content of .SPl file in C#.net Pin
Member 1109382422-Sep-14 21:06
Member 1109382422-Sep-14 21:06 
QuestionRe: how to read content of .SPl file in C#.net Pin
George Jonsson22-Sep-14 22:13
professionalGeorge Jonsson22-Sep-14 22:13 

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.