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

  • Home
  • SEARCH
  • 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 3600042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:26:40+00:00 2026-05-18T20:26:40+00:00

imagine this code for (int iDay = 1; iDay <= total_days; iDay++) { question

  • 0

imagine this code

for (int iDay = 1; iDay <= total_days; iDay++)
{

    question = CheckString(s.challenge_1_q);
    answer = CheckStringA(s.challenge_1_a);

    // more here
}

but what I really have is from challenge_1_q to challenge_24_q and challenge_1_a to challenge_24_a

what is my best option to have dynamic variables as today it’s 24, “tomorrow” could be only 18.

is the use of dynamic the proper way? or I really need to have a switch and forget about dynamism ?

  • 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-18T20:26:41+00:00Added an answer on May 18, 2026 at 8:26 pm

    Create a class called QuestionAnswer, then store a List on s.
    The accessing code will look like this:

    question = CheckString(s.QuestionAnswers[i].Question);
    answer = CheckStringA(s.QuestionAnswers[i].Answer);
    

    The QuestionAnswer class:

    public class QuestionAnswer
    {
      public string Question{get; set;}
      public string Answer{get; set;}
    }
    

    And the definition on your existing class:

    public List<QuestionAnswer> QuestionAnswers = new List<QuestionAnswer>();
    

    Instead of having dozens of variables, you add dozens of items to the list:

    QuestionAnswer qa = new QuestionAnswer();
    qa.Question = "What letter comes after A?";
    qa.Answer = "B";
    QuestionAnswers.Add(qa);
    //repeat for all your questions.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

imagine this code for (int iDay = 1; iDay <= total_days; iDay++) { question
I imagine this is a pretty hard question to answer without sitting down and
I imagine that this is a simple question, but I'm getting some strange results
I've never learnt JavaScript, but I imagine this is quite a simple problem. Just
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I created this 2D Qlist. Code works but when I consider a bit deeper
Apologies if this is a stupid/easy question, but still getting used to everything in
I asked this question to get some opinions on the subject of glue code.
Imagine this directory structure: app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py mod2.py I'm coding
Imagine this sample java class: class A { void addListener(Listener obj); void removeListener(Listener obj);

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.