Back in the year 2000, a team at Microsoft came up with a new programming language: C#. Microsoft came up with C# as a part of its .NET initiative, and the language works within the .NET framework. But there are a ton of different programming languages out there, and that was already the case back in 2000 – Java predates C# by five years, Python predates it by more than a decade, and C predates it by nearly thirty years! So what is the point of another programming language? What is C#, and what makes it special? What is it used for, and what can programmers do to make sure that it’s used properly while avoiding errors?
What is C#?
C# is a programming language – one of many that you might have heard of.
C# is part of the C family of programming languages. There’s another programming language known simply as C, and it’s on of the most important programming languages in history. The C language spawned a whole family of languages – the C family – that includes notable languages like C++ and, of course, C#.
The C# name comes from music (“C sharp”). Since a sharp moves a note a half-step up, you can see that C#’s developers wanted C# to be known as a step (or a half-step, technically) above the competition!
C# is largely an object-oriented language, which means that it’s organized around data – “objects” – rather than actions (or “logic”). But C# is more accurately described as a multi-paradigm language. While it’s object-oriented in many ways, it’s not limited to that paradigm.
What is C# used for?
Because it is so simple, modern, and powerful, C# is used in a huge variety of projects across a wide range of industries. C# is used to build payroll systems, mobile applications, data storage, dynamic websites, and even compilers.
And C# is still a relatively young language – it just came on the scene in 2000. Its third-party support is limited but growing, and there’s every reason to believe that it will remain an important language in the years to come – and perhaps even become more important with each passing year.
Working with C#
C# is an incredibly powerful language, but it’s not without its quirks. You’re bound to run into some exceptions (errors) with your code from time to time, but fear not – if you follow C# exception handling best practices, you’ll be just fine.
C# programmers can use a few keywords – try, catch, finally, and throw – to find and diagnose issues in their code. Putting try in your code along with brackets can isolate one section of your code to run. A corresponding catch will execute if you get an exception in your try block. Using finally will execute a catch regardless of whether or not there has been an exception, and throw will actually create a new exception, which is useful in certain situations.