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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:16:24+00:00 2026-05-29T06:16:24+00:00

private static readonly Dictionary<int, LocalizationLanguage> _languages = new Dictionary<int, LocalizationLanguage>() { {0,new LocalizationLanguage {

  • 0
    private static readonly Dictionary<int, LocalizationLanguage> _languages = new Dictionary<int, LocalizationLanguage>() {
    {0,new LocalizationLanguage { CultureInfo = "en-US", Id = 0 }},
{1,new LocalizationLanguage { CultureInfo = "es-AR", Id = 1 }}
    };

I have this declaration, and it doesn’t autowrap into something nice, whereas if I do the exact same but with a property accessor, it formats perfectly to:

    private static Dictionary<int, LocalizationLanguage> _languages
    {
        get
        {
            return new Dictionary<int, LocalizationLanguage>()
               {
                   {0, new LocalizationLanguage {CultureInfo = "en-US", Id = 0}},
                   {1, new LocalizationLanguage {CultureInfo = "es-AR", Id = 1}}
               };
        }
    }

What’s the reason for this and how can I make either vs2010 or R# auto-format this kind of expressions?

  • 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-29T06:16:25+00:00Added an answer on May 29, 2026 at 6:16 am

    I’ve just tested this myself, as I use vs2010 and R# myself. It automatically reformats the code to:

    private static readonly Dictionary<int, LocalizationLanguage> _languages =
        new Dictionary<int, LocalizationLanguage>()
            {
                { 0, new LocalizationLanguage { CultureInfo = "en-US", Id = 0 } },
                { 1, new LocalizationLanguage { CultureInfo = "es-AR", Id = 1 } }
            };
    

    vs2010 reformats the code upon completion of the statement (entering the ;). I tested by pasting your unformatted code into visual studio, and erasing the final };. Typing it again automatically formats it. I also tested having different variations of the original code before closing the statement and it formats it the same no matter what.

    I would guess there is an issue with your vs2010 or R# in this case?

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

Sidebar

Related Questions

Currently, my code resembles this: private static readonly int[] INTARRAY = {1, 2, 3};
So I have the following: public class Singleton { private Singleton(){} public static readonly
private static Dictionary<Type, Func<string, object>> _parseActions = new Dictionary<Type, Func<string, object>> { { typeof(bool),
I have this CacheManager class which keeps a static dictionary with all sorts of
// Member Variable private static readonly object _syncLock = new object(); // Now inside
In my usercontrol.xaml.cs. I have this dependency proprerty as bleow. public static readonly DependencyProperty
I have the following code: private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); XmlConfigurator.Configure(new FileInfo(log4net.config));
I have a class as following public class ScheduledUpdater { private static readonly object
I have a class namespace LogToolsTest { public class Foo { private static readonly
How do you convert the following C# code to VB.NET? private static readonly ICollection<string>

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.