Learn why you need to care about C#.
Published: January 13, 2010
Validated with Amaya
By Richard G. Baldwin
XNA Programming Notes # 0102
|
This tutorial lesson is part of a continuing series dedicated to programming with the XNA Game Studio. As I mentioned in an earlier lesson, I am writing this series of lessons primarily for the benefit of students enrolled in an introductory XNA game programming course that I teach. However, everyone is welcome to study and benefit from the lessons.
An earlier lesson titled Getting Started (see Resources) provided information on how to get started programming with Microsoft's XNA Game Studio. (See Baldwin's XNA Programming Tutorials in Resources.)
This is not a beginning programming course. The official prerequisite for this course is a course in programming fundamentals using C++. That course uses C++ strictly as a procedural programming language. The course is currently taught using a very simple IDE known as Dev C++.
I will assume...
Therefore, I will assume that students in this course already know how to program using C++ as a procedural programming language and that they already understand such fundamental concepts as programming logic, functions, parameter passing, etc.
I will also assume...
At the same time I will also assume that the students in this course know very little if anything about the following topics:
These are all topics that will be important in learning how to make effective use of the Microsoft XNA Game Studio software.
According to Wikipedia,
"C# (pronounced "see sharp") is a multi-paradigm programming language encompassing imperative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within the .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages designed for the Common Language Infrastructure."
"C# is intended to be a simple, modern, general-purpose, object-oriented programming language.[3] Its development team is led by Anders Hejlsberg, the designer of Borland's Turbo Pascal, who has said that its object-oriented syntax is based on C++ and other languages.[4] James Gosling, who created the Java programming language in 1994, called it an 'imitation' of that language.[5] The most recent version is C# 3.0, which was released in conjunction with the .NET Framework 3.5 in 2007. The next proposed version, 4.0, is in development."
That is certainly a mouthful.
From the viewpoint of students in this course, here is some of what C# really is and why you should care about C#.
Complex IDE
To begin with, C# was designed to run in a large complex IDE. For example, using the Visual C# IDE to create the simple Hello World program shown in Listing 1 generates about thirteen different files in about ten different folders.
Listing 1. Hello World in C#. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Hello01{ class Hello01{ static void Main(string[] args){ Console.WriteLine("Hello C# World"); //Press any key to dismiss console screen. Console.ReadKey(); }//end Main }//end class }//end namespace |
Is there a simpler way?
While is it possible to develop simple C# programs outside the IDE (see Baldwin's C# programming tutorials), there are probably less than a few hundred people worldwide who do it that way.
The transition from the relatively simple Dev C++ IDE to the very complex Visual C# IDE may be a stretch for some students.
Fully object oriented
C# is an object-oriented programming language. Unlike C++, it is not possible to develop C# projects without taking the object-oriented nature of C# into account.
Massive and complex documentation package
The object-oriented nature of C# becomes very apparent when attempting to locate something in the massive XNA documentation package. The documentation is written from an object-oriented viewpoint. For example, see the documentation for the Microsoft.Xna.Framework.Graphics namespace here and see the documentation for the SpriteBatch class here.
Indirection
C# makes extensive use of indirection. While the indirection scheme used in C# is not as complicated as C++ pointers, for someone new to indirection, understanding the concept can sometimes be a challenging task.
C# is the language of XNA
C# is the programming language of the Microsoft XNA Game Studio. To write XNA programs, you must know how to write C# programs.
That is why you should care about C#. I won't try to turn you into a C# programming expert in this course. We have other courses at the college that concentrate solely on C# programming. Instead, I will try to help you learn enough about C# programming that you can do a credible job of writing XNA programs.
Copyright 2009, Richard G. Baldwin. Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.
Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is object-oriented programming using Java and other OOP languages.
Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas. He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers.
In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP). His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments. (TI is still a world leader in DSP.) In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.
Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.
-end-