ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Application development Toolkit

Why you should move to C#

Craig Utley Builder.com

Published: 07 Nov 2002 11:13 GMT

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

If you are moving to .Net and you already know C++ or Java, C# is a logical choice. However, if you are undecided about .Net, you might wonder why you'd want to move to C# rather than stick with your COM-based C++. Often the decision to move to .Net is based on factors other than learning C#, but C# does offer advantages over any COM-based language, thanks to the .Net Framework. This article examines 10 reasons to make the move to C#.

Modernised language
C# is a modernised version of C++. Originally you had the language C, which was widely used. C++ came about to add object-orientation to C, and C++ became the language of building "real" applications for Windows (according to the C++ developers.) C++ was used for writing the infrastructure and low-level applications, while Visual Basic developers wrote business applications.

C# brings the rapid development model of VB to the world of C++ developers, with some obvious changes. C# takes advantage of the .Net Framework, which means you have access to a powerful forms engine, just like VB developers have had for years. New data types have been added, such as the decimal data type for performing financial calculations.

Type-safety
C# is type-safe, which means several things. For example, you cannot use uninitialised variables. In C++ it is easy to declare a variable and then check its value; whatever was in the memory address given to that variable would then be shown, and this could wreak havoc on an application. The C# complier will notify you if you try to use a variable before you have initialised it to some valid value.

With C#, you can no longer just walk past the end of an array, as you have been able to do in C and C++ for ages. In C++ you could declare an array of three elements and then happily examine the fourth element of that array and get the next chunk of memory.

Object-oriented
While many would argue that C++ is object-oriented, C# goes to another level. Even simple data types can be treated as objects, meaning that an int has methods associated with it. For example, you can use the ToString method to get a string value for an int, as shown below. int Counter=14;
Console.Write(Counter.ToString());

In addition, literal strings can be treated as objects and support a variety of methods, such as Trim, ToUpper, ToLower, and many others, as shown here:
Console.Write("hello, world".ToUpper());

Simplified syntax
While C++ is an extremely powerful language, it has not typically been considered easy. C# attempts to simplify the syntax to be more consistent and more logical while also removing some of the more complex features of C++. For example, C# does away with pointers. As a type-safe language, C# doesn't allow direct memory manipulation, so pointers are no longer needed in C#.

Header files have also been removed from C#. The namespace and reference operators, :: and -> respectively, have been replaced with a single operator, the period (.).

Perhaps one of the biggest changes is that the int and bool data types are now completely different. This means that you will finally have an end to the assignment vs. comparison problem in if statements. In other words, the following code will not even compile under C#:
int Counter=14;
if (Counter=14) { //do something }

Attempting to compile this code will return an error stating:
Cannot implicitly convert type 'int' to 'bool'

C# also removes memory management issues from the developer by using .Net's garbage collection scheme. Items no longer referenced are marked for garbage collection, and the Framework can reclaim this memory as needed.

Next

Previous

1 2


  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Dell

Did you find this article useful?
48 out of 91 people found this useful


Full Talkback thread

0 comments


Company/Topic Alerts

Create a new alert from the list below:











Related Jobs

.Net Web Applications Developer, ASP.Net, C#, VB.Net, SQL in Bristol

They need someone with experience in VB.Net, ASP.Net and SQL Server. You will be using VB.Net, The client is one of the UK's major insurance names, ...

PL/SQL Programmer with VB.NET & Japanese Insurance Client 40k

PL/SQL Programmer with VB.NET & Japanese req.for Insurance Client 40k My client are one the world biggest Insurance companies with global offices and ...

VB.Net web developer (west Midlands)

A proficient ASP.Net web developer with strong VB.Net skills is required by a west midlands client to develop an interactive site. The suitable ...

Discussions

187205 187205

Companies to react to downtime

Thursday 24 July 2008, 2:51 PM

1 comment
pearce_jj pearce_jj

Defragging: Merits?

Thursday 24 July 2008, 2:19 PM

13 posts
David Long David Long

Defragging: Merits?

Thursday 24 July 2008, 10:30 AM

13 posts

Featured Talkback

The fact is: Software developers today are really designers and not coders. The reason that business anlaysts exist today to model solutions is because they understand the value of designing software before writing it. All too often developers create code that has little value because they do not understand that business classes interact with other classes within the confines of a working model or pattern.

By: 1000165269

Read full story:
Making sense of agile modelling