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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:14:43+00:00 2026-05-23T17:14:43+00:00

That can be silly question but I really don’t know the reason. // i

  • 0

That can be silly question but I really don’t know the reason.

    // i is compiled as an int
    var i = 5;

    // s is compiled as a string
    var s = "Hello";

    // a is compiled as int[]
    var a = new[] { 0, 1, 2 };

    // expr is compiled as IEnumerable<Customer>
    // or perhaps IQueryable<Customer>
    var expr =
        from c in customers
        where c.City == "London"
        select c;

    // anon is compiled as an anonymous type
    var anon = new { Name = "Terry", Age = 34 };

    // list is compiled as List<int>                             
    var list = new List<int>();

If so, why C# needs integral types like int, string, int[], List<> ? If we can do that only with var keywords, why are there integral types?

Another way,

What is the difference between these ?

var s = "Hello";
string s = "Hello";
  • 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-23T17:14:44+00:00Added an answer on May 23, 2026 at 5:14 pm

    in no particular order…

    • var is only a compiler construct; even var i = 4; is typed as int
    • C# hasn’t always had var, and you can’t remove keywords without utterly breaking existing code.
    • you can only use var in method variables – not fields, parameters, return types etc.
    • most people are happy to type int in place of var! Especially when the type matters and there are bytes, floats, enums, decimals etc that all work with the literal 0; i.e. short x = 0; int y = 0; long z = 0; – why change only int to var there?
    • you can’t use var to specify a generic type parameter (<T>) or in a typeof
    • you can’t use var.TryParse in place of int.TryParse
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon, I'm sorry if this question is too silly, but I don't know
Hey Everyone, This question seems really silly to me, but I can't for the
umm... silly question. I know that one can (and should) use APC cache driver
This is perhaps a silly question, but I can't seem to find out how
That's a mouthful of a question but basically I want to know if I
I know very little about OOP, so maybe my question is silly, but still....
I feel kind of silly asking this question as it seems really simple, but
Sorry if I missed something and this is a silly question...but can I enter
It's a silly question but I couldn't find an answer to that : I'm
I'm sorry for such a silly question, but I can not fathom the name

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.