Difference between the implementation of var in Javascript and C#

后端 未结 5 742
情深已故
情深已故 2020-12-29 20:33

I would like to ask a theoretical question. If I have, for example, the following C# code in Page_load:

cars = new carsModel.carsEntities();

var mftQuery =          


        
5条回答
  •  有刺的猬
    2020-12-29 21:09

    And to answer your question 1, the benefit of using var keyword in the presented code is at may be difficult to come up with the resulting type for the LINQ query and can be easily affected by the change to the query. In fact, its introduction to C# coincide with the premiere of LINQ.

    Reassuming, it is to make the life of programmer easier and also to remove the redundancy of Type t = new Type().

提交回复
热议问题