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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:50:05+00:00 2026-05-17T16:50:05+00:00

I just started using Resharper. One of its features is that it suggests changes

  • 0

I just started using Resharper. One of its features is that it suggests changes to the code based on, i suppose, good coding practices.

One of the changes it suggested is to change the variable type to var during assignment. I kept on changing and now the code has var everywhere. Somehow I get the feeling that “var” keyword makes the code a bit difficult to understand.

Is it a good coding practice to use “var” whereever possible or is it better to stick with the actual type. (except anonymous types where its required to use “var”)

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-05-17T16:50:05+00:00Added an answer on May 17, 2026 at 4:50 pm

    The C# programming guide suggest using var when it enhances readability, for instance when the type is obvious, too complicated or not important at all.

    The var keyword can also be useful
    when the specific type of the variable
    is tedious to type on the keyboard, or
    is obvious, or does not add to the
    readability of the code. One example
    where var is helpful in this manner is
    with nested generic types such as
    those used with group operations. In
    the following query, the type of the
    query variable is
    IEnumerable<IGrouping<string, Student>>. As long as you and others
    who must maintain your code understand
    this, there is no problem with using
    implicit typing for convenience and
    brevity.

    There is no general rule. There are situations where the explicit type may enhance readability.

    Examples:

    var x = new Thingy(); //type is obvious
    
    var x = dict.Where(x => x.Value > 3); // type is complex and not important
    
    Foo(GetValue(FromOverThere())); // type is implicit anyway
    
    // equivalent to:
    var fromOverThere = FromOverThere();
    var value = GetValue(fromOverThere)
    Foo(value);
    
    FooDocument doc = repository.Get(id); // glad to see the type here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started using Resharper with VS-2008, and one of the 'errors' it
just started using JPA today, so i'm preety new to it. How would one
Just started using Apache Commons StringEscapeUtils . According to http://www.w3schools.com/tags/ref_entities.asp , &Ouml; should correspond
I just started using jQuery. Now I want to use an jQuery method with
I just started using NLog in my asp.net application, and I need to see
I just started using Git recently and I was reading up on Git best
I just started using Maven with eclipse and deployed my application to WebLogic. When
I just started using EF, and heres what I have: dataEntity = new ThisProject.Data.Entities();
I've started exporting some of my frequently used blocks of code to custom snippets.

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.