From that diagram I stopped following around 3.0... lambdas and LINQ can be very useful but I don't really like var and everything later is gibberish to me.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Anyone else trying to keep up with all the newish .NET stuff?
Collapse
X
-
Originally posted by MaryPoppinsI'd still not breastfeed a naziOriginally posted by vetranUrine is quite nourishing -
var is useful in a its usually x but occassionally could be y department.Originally posted by d000hg View PostFrom that diagram I stopped following around 3.0... lambdas and LINQ can be very useful but I don't really like var and everything later is gibberish to me.
likewise optional parameters just keep the code a bit neater you don't end up with 5 functions for variations of input.merely at clientco for the entertainmentComment
-
I use implicit var and linq/lambdas all the time. Rest of the gibberish, I wash my hands of it
I am Brad. I do more than the needful and drive the market rates up by not bobbing my head.Comment
-
Isn't that what interfaces are for?Originally posted by eek View Postvar is useful in a its usually x but occassionally could be y department.
I suppose in C++ we already had part of that with default parameters, which never seemed to take on elsewhere. Though it wasn't a very elegant implementation... named+optional parameters I can see making sense.likewise optional parameters just keep the code a bit neater you don't end up with 5 functions for variations of input.Originally posted by MaryPoppinsI'd still not breastfeed a naziOriginally posted by vetranUrine is quite nourishingComment
-
var goes hand in hand with linq. It solves the issue where linq returns something that the programmer wasn't expecting.Originally posted by d000hg View PostIsn't that what interfaces are for?
I suppose in C++ we already had part of that with default parameters, which never seemed to take on elsewhere. Though it wasn't a very elegant implementation... named+optional parameters I can see making sense.merely at clientco for the entertainmentComment
-
If it returns something I wasn't expecting, I'd rather know about it than have things merrily go on doing something I hadn't planned on!Originally posted by MaryPoppinsI'd still not breastfeed a naziOriginally posted by vetranUrine is quite nourishingComment
-
I think you might have misunderstood that.Originally posted by eek View Postvar goes hand in hand with linq. It solves the issue where linq returns something that the programmer wasn't expecting.
"var" was put there to handle anonymous types - as a programmer you should know what those look like because they are limited to the body of a method. If you want one of those to escape your method (outside of closures) you're just dealing with the "object" type again and are going to need to use reflection to get at its properties.
I use "var" all the time too, do not see the need to mention the type twice when you're creating an object. I'm a bit more explicit with declarations when something is being returned from a method however.
When you declare a variable with "var" you cant just change its type like you can with a dynamic language - it's fixed due to C#'s static typing.Comment
-
Yes. To me, var means "I'm a lazy bugger. The compiler knows the type, the VS.NET knows the type, so why should I bother typing it in?"Originally posted by Jaws View PostI think you might have misunderstood that.
"var" was put there to handle anonymous types - as a programmer you should know what those look like because they are limited to the body of a method. If you want one of those to escape your method (outside of closures) you're just dealing with the "object" type again and are going to need to use reflection to get at its properties.
I use "var" all the time too, do not see the need to mention the type twice when you're creating an object. I'm a bit more explicit with declarations when something is being returned from a method however.
When you declare a variable with "var" you cant just change its type like you can with a dynamic language - it's fixed due to C#'s static typing.
Comment
-
Another gem seen in some code today.
Checking if x >= 0 and <=100Code:if (Enumerable.Range(0,100).Contains(x)) { // do stuff }
Comment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Burnham's housing vision vs. Starmer's home-buying reforms: what it means for your contractor mortgage Jul 22 00:59
- In Khalil v Innovate Transport, a limited company contractor wasn’t a worker and was on £2.30 — not £230 Jul 21 07:58
- Andy Burnham is PM: 5 new IT policies set to shape UK tech and its contractors Jul 20 06:29
- Taxed on money I haven't earned yet? Bold move, HMRC Jul 17 08:36
- The Fair Work Agency has got zero hours in its sights. Do you? Jul 16 08:44
- Cookie Policy Jul 15 11:50
- Cloned again: an umbrella company founder's warning on fraud, JSL and Companies House Jul 15 07:47
- How is JSL bedding in for contractor umbrella companies, 100 days in? Jul 14 07:45
- IT contractor demand cools in June 2026 amid UK heatwave Jul 13 08:18
- How could zero hours contract reform create unexpected problems for contractors? Jul 8 06:40

Comment