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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:07:36+00:00 2026-06-17T08:07:36+00:00

Simple syntactic c# question is this. Given this code: List<string> Columns = new List<string>();

  • 0

Simple syntactic c# question is this.

Given this code:

List<string> Columns = new List<string>();
List<string> Parameters = new List<string>();
List<string> Values = new List<string>();

It can be reduced to:

List<string> Columns = new List<string>(), Parameters = new List<string>(), Values = new List<string>();

But can I get it shorter still, since they’re all being initialised to an empty list?

Thank you all!

  • 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-17T08:07:37+00:00Added an answer on June 17, 2026 at 8:07 am

    I can recommend to use var keyword if these variables are not class fields, because types are know from usage. It really makes no sense to flat declaration of three variables.

    var Columns = new List<string>();
    var Parameters = new List<string>();
    var Values = new List<string>();
    

    Yes, you can do things, like declaring multiple local variables in one line and then initializing them in one line. But please, avoid declaring multiple variables in one line – it makes code much readable.

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

Sidebar

Related Questions

my question today is pretty simple: why can't the compiler infer template parameters from
Simple issue but I'm at a loss to debug this further. I followed the
Simple question - How do I convert a string that has been through parseInt
Simple question, could'nt find a straight answer. How can I modify the output file
Just want to make simple extension for syntactic sygar : public static bool IsNotEmpty(this
I'm pretty new to jQuery, so this is basically a syntactical question. I'm using
Simple question, is it possible to achieve this query this with Entity Framework when
This is about syntactic sugar in Haskell. A simple Haskell program: main = do
Simple question, (Easy points!) In Delphi 2010 (with updates 4 and 5) Find in
Simple question: Is there a class or interface that encapulates the getting of a

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.