NB2: Some people vehemently oppose any use of var beyond anonymous types. And it certainly can be overused - for example, var x = Foo(); would compile, but is not readable. But for a new expression, where the type is right next to the variable declaration, I don't see any problem with using var.
NB3: To clarify, based on the responses: using var for new expressions is fine; you should generally avoid it for anything else.
var x = new SomeType(); is fine.
var x = SomeMethod(); is bad.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Until you get to Linq, you should have a good idea what type you are using - particularly when you are just starting. I think explicit typing helps beginners rather than confuses them when they suddenly find it "won't pass x to method y" and can't understand why not.
But hey! I'm not going to start a flame war about it!
Sent from my Amstrad PC 1640 Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
Yes that is true but it's good to know that 'var' exists.
I find that I'm best at learning programming by studying medium sized programs. I like to step thru a program to see how it works. I also try to write a simple C# program from what I have learnt.
I suspect the biggest thing that turns beginners away from learning C# is when their program is fulled with errors and they have no idea on how to fix the problem or where they went wrong as they have tried to build a complex program before fully learning C#. Jumping in the deep end as they say.
Things like l1.addExit(new Exit(Exit.Directions.North, l2)); takes a bit of getting use to but I'm keen to learn and are starting to understand it more.
I suspect the biggest thing that turns beginners away from learning C# is when their program is fulled with errors
When I see a student whose code is full of errors (beyond typos), I see a student who is not being guided properly, or, a student who is "flailing" because they have not grounded themselves in language basics, or don't know how to study in a disciplined way.
Once you make some progress in getting over the initial learning curve with C#, I predict you will look back on VB and Python as the messes they are
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
Currently I'm using version 2015 if Visual Studio and was wondering if anything happened to my computer and I had to reinstall Visual Studio then would I still be able to install version 2015. I remember that you run a small program that caused it to download and install itself (unless there is a way to download the complete file for storage)
I was told that there were some issues with version 2017 so I'm staying with version 2015 at the moment.