Using the var keyword in C# to declare variables does save you some thought and can seem to speed things up, but as pointed out by Ian Griffiths in his books about programming in C#, "...although var saved you some work when you wrote the code, that gain is quickly wiped out by the additional thought required every time you go back and look at the code."
That said, there are some situations in which var is warranted. One is to avoid writing the name of the type twice.
So this:
List<int> numbers = new List<int>();
Can be written as:
var numbers = new List<int>();
You can drop the first List<int> without making this harder to read because the name is right there in the initializer.
C# supports anonymous types, and as the name suggests, it’s not possible to write the name of such a type. In these situations, you may be compelled to use var. (In fact, the var keyword was introduced to C# only when anonymous types were added.)
12 January 2020
10 January 2020
Scanning a QR-Code for Wi-Fi Access
There is an app available on the Microsoft Store that enables you to scan a QR code using your laptop's camera and then it will join that Wi-Fi network. For example, at a café I was given the Wi-Fi password and I used it to join the Wi-Fi with my phone. Then I was able to open my network settings on my phone which presented me with the QR code and I could just show that to my laptop's camera to join, without having to re-enter the password.
08 January 2020
Subscribe to:
Posts (Atom)
-
Creating multiple Google Chrome profiles is fairly easy on a PC, there's even a program for doing all the legwork for you . Not so...
-
From the Google Toolbar menu's Help > About Here is a translation from the Latin. WORD FOR WORD de - from ; parvis - little thin...
-
Here's a snippet from the book : The Wolfram Language seems too easy; is it really programming? Definitely. And because it automates awa...