Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
QuestionRegarding a basic question about Serialization Pin
Tridip Bhattacharjee23-Sep-14 21:26
professionalTridip Bhattacharjee23-Sep-14 21:26 
AnswerRe: Regarding a basic question about Serialization Pin
Eddy Vluggen23-Sep-14 21:50
professionalEddy Vluggen23-Sep-14 21:50 
AnswerRe: Regarding a basic question about Serialization Pin
George Jonsson24-Sep-14 18:14
professionalGeorge Jonsson24-Sep-14 18:14 
AnswerRe: Regarding a basic question about Serialization Pin
Sibeesh KV24-Sep-14 18:43
professionalSibeesh KV24-Sep-14 18:43 
Questionusing Peachtree API in C# Pin
Jassim Rahma23-Sep-14 11:08
Jassim Rahma23-Sep-14 11:08 
AnswerRe: using Peachtree API in C# Pin
jschell23-Sep-14 11:58
jschell23-Sep-14 11:58 
QuestionIterate over a Collection-Type for its Values using Reflection Pin
Agent__00723-Sep-14 1:48
professionalAgent__00723-Sep-14 1:48 
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 

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.