Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:09:59+00:00 2026-05-24T02:09:59+00:00

for a test I need to make a list with some parameter settings. This

  • 0

for a test I need to make a list with some parameter settings. This list is not per definition pre-defined as a type and / or what’s in it.

bool[] trueOrFalse = new bool[] { true, false };
        int[] para1 = new int[] { 1, 2, 3 };
        int[] para2 = new int[] { 5, 6, 7 };
        int[] para3 = new int[] { 1, 2, 3 };
        int[] para4 = new int[] { 5, 7, 9 };

        List<object> test = (from a in trueOrFalse
                   from b in para1
                   from c in para2
                   from d in para3
                   from e in para4
                   let f = c - d
                   where c - d <= 3
                   select new { a, b, c, d, e, f }).AsEnumerable<object>().ToList();

the result is fine (this is just for a test) and I do get a list back with all the parameter combinations possible, which I can use as a parameter for another method. (I need it as a list, because, as far as I know, var test cannot be parsed as a parameter to another method.)

When I hover above test in debug mode, I can see each row and each row contains a to f as a separate field.

But how can I subtract the values?

let say I want to use a foreach loop over the list.

how can I set int myA = a etc?
regards,

Matthijs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:10:00+00:00Added an answer on May 24, 2026 at 2:10 am

    Well, you’re explicitly removing type information by calling AsEnumerable<object>. Just get rid of that, and use var for the variable:

    var test = (from a in trueOrFalse
                from b in para1
                from c in para2
                from d in para3
                from e in para4
                let f = c - d
                where c - d <= 3
                select new { a, b, c, d, e, f }).ToList();
    

    Then you can do:

    foreach (var item in test)
    {
        Console.WriteLine(item.a); // Strongly typed at compile-time
    }
    

    Now, I had previously missed the “which I can use as a parameter for another method” part. (You can still use a list – but it’s a list of an anonymous type.) Using anonymous types, you really pass the result to a method in a strongly-typed way.

    Options:

    • Create a named type with all the relevant data, so you can keep it in that form in a strongly typed way.
    • Use type inference for the method that you’re passing the data to (that may or may not be feasible; it’s not clear what you’re doing).
    • Use dynamic typing in C# 4 to get around normal static typing in C#.
    • Access the properties using reflection.

    If you can tell us more about what you’re doing in the other method, that would really help. If the method can be made generic, you may well still be able to use anonymous types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test an application and I need to make an valid IP
My point is this. For test i need when user check chk1 the chk2
I need to test a url that it does not end with .asp So
Code snip 1) does not compile, and I need e.g. to make the cast
I inherited this code and now need to make modifications. I have a series
for some test I need to run a data driven test with a configuration
As part of a numerical library test I need to choose base 10 decimal
I need to test whether various types of database objects exist in a given
I need to test a serial port application on Linux, however, my test machine
I need to test a site with a dynamic menu in Mac Firefox, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.