#181 – C# Is Strongly Typed

C# is a strongly typed language, meaning that every variable and object has a well-defined type.  At compile-time, the compiler checks to make sure that all operations use objects of the correct type.  This generally means that if a function takes an argument of type double, you’ll get a compile-time error if you try to pass it something that is of a different type.

There are many benefits of using dynamically typed languages (e.g. Python, Ruby).  However, the main advantage of a strongly typed language is that errors related to type conversion are caught at compile-time rather than at run-time.  It’s always better to find a bug earlier, rather than later.  Finding a bug at compile-time forces the developer to fix it.  Finding it at run-time means that the bug might only be found by a customer, after the product has shipped.

Exception: the dynamic keyword

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #181 – C# Is Strongly Typed

  1. Pingback: #182 – C# is (Mostly) Strongly Typed « 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers