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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:19:52+00:00 2026-05-23T16:19:52+00:00

Is it pretty common to declare it near the bottom in C# code? I

  • 0

Is it pretty common to declare it near the bottom in C# code?

I seen few example where its done that way.

There are tools like Resharper which help you organize your source code, does it have an option to specify where it should create regions for me?

  • 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-23T16:19:52+00:00Added an answer on May 23, 2026 at 4:19 pm

    This is a stylistic discussion because with the majority of compilers the placement at the top or bottom (of a class file) doesn’t affect the results. Historically a lot of people do it at the top, but I like to leave them at the bottom.

    Why?

    Because once I’ve declared that member variable, I don’t need to see it anymore – it shows up in my intellisense, so I don’t need it in my face. When you open a file, you see the top – I want to see my code straight away, not a bunch of variable declarations. This is especially relevant because variable definitions are not a natively collapsible region in the VS editor, so if they’re at the top you are forced to scroll past them. If I need to jump to it then Visual Studio’s F12 or just a Ctrl+End will take me there.

    This is a style that some may find hard to deal with initially, but it does grow on you quite quickly. This is a particularly good approach on files that are more mature. You will also find that if you are using a plugin like ReSharper it is smart enough to put generated declarations with all the others – which means if you have them at the bottom that’s where ReSharper will put it. Of course this can get messy if you have multiple classes in a file, but if you do then variable definition placement is the least of your stylistic issues.

    Edit:

    at the risk of drifting off topic, a comment on using a #region block instead: I use regions all the time, I love them because they help me collapse code down out of the way. However using them requires discipline as it is easy for non-related code to make its way inside the region. How many times have you looked for code only to find it buried in a #region where it didn’t belong?

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

Sidebar

Related Questions

I have a pretty common layout issue that I have traditionally used a table
While writing code, it is pretty common to request a page with an appended
This is a pretty common topic and has many answers out there. Situation :
It's pretty common knowledge that JQuery is in both the Microsoft and Google CDN,
I think this is a pretty common scenario: I have a webpage that's returning
I couldn't find this anywhere, partly because its keywords are pretty common. $('.pause_button').text('<img src=../imgs/icons/control_pause_blue.png
When dealing with debugging queries using Profiler and SSMS, its pretty common for me
this should be pretty common yet I find it fascinating that I couldn't find
It's pretty common that I'm in a quickfix, nerdtree, or other special window and
I have included reset.css which is pretty common for most websites that use, on

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.