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 8884283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:01:32+00:00 2026-06-14T21:01:32+00:00

I am new to C# i have these many string values in my code

  • 0

I am new to C# i have these many string values in my code as

string text1 = textbox1.text;
string text2 = textbox2.text;
string text3 = textbox3.text;
string text4 = textbox4.text;

and some bool values as well

bool chk1 = checkBox1.Checked;
bool chk2 = checkBox2.Checked;
bool chk3 = checkBox3.Checked;   

also i have checkboxes types to be true

checkBox2.Checked = true;
checkBox3.Checked = true;
checkBox4.Checked = true;
checkBox5.Checked = true;

the checkbox part is basically at form load
Is there a way to write some neat code and reduce no. of lines?

Thanks

  • 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-06-14T21:01:33+00:00Added an answer on June 14, 2026 at 9:01 pm

    Use arrays:

    string[] texts = { textbox1.Text, textbox2.Text, textbox3.Text, textbox4.Text };
    
    bool[] checks = { checkBox1.Checked, checkBox2.Checked, checkBox3.Checked };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these three lists with the same number of elements List<String>competitoinsIDs = new
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
hi im new to jquery and im facing these problem i have these code
I have these urls: http://localhost:3000/assets http://localhost:3000/assets/new http://localhost:3000/assets/34 http://localhost:3000/assets/34/edit they work in my app. I
I have these two modules : package G1; sub new { my $class =
I have these 2 routes : routes.MapRoute(Agenda, ConfigurationManager.AppSettings[eventsUrl] + /{year}/{month}, MVC.Events.Index(), new { year
How can I have each of these a elements break on to new lines,
I have a dijit.form.NumberTextBox input field that starts out with these parms: new dijit.form.NumberTextBox({
I have a vector of pointers to class objects. These class objects invoke new
I have the following section of code that acts on values in <Test></Test> nodes

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.