I have a method like below
public List<aspnet_Roles> GetAllRoles() { var rolesList = _dbProfile.aspnet_Roles.ToList(); return rolesList; }
In this method, all roles from the database (LINQ to SQL) were first restored and assigned to the rolesList variable of type var .
I want to know whether it is better to return a value, instead of assigning it to other variables first and then returning it.
This method is lower than the previous version:
public List<aspnet_Roles> GetAllRoles() { return _dbProfile.aspnet_Roles.ToList(); }
Will the above method compile in IL as the same or second version? The second version does not have an unnecessary variable declaration.
source share