David Klempfner
Dec 16, 2021

Interesting article, thanks for writing. You wrote "The true function of var is to allow us to declare a local variable when you don’t know what type it is". There's more to it than that. You can use var to avoid duplicating a long type name, eg:

var c = new CrazyFrigginLongClassName();

vs

CrazyFrigginLongClassName c = new CrazyFrigginLongClassName();

It also keeps your code DRY because if you want to change the type, you can just leave "var" as it is.

You can also hover the cursor over var and it'll tell you the type, and if you have Resharper, it even tells you the type as a comment at the end of the line.

Also there's a typo in OrdinalIgnireCase.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

David Klempfner
David Klempfner

Written by David Klempfner

I’m a software developer who is passionate about learning how things work behind the scenes.

No responses yet

Write a response