Getting Started With C#/.NET Development

C# is an object-orientated programming language, which I commonly describe as being the love-child between C++ and Java. With the borrowed Java elements being much more prodominant, so if you already have experience writing Java programs and applications, much of this will look very familiar. At the very least, as long as you've been programming in one modern language or another for the last 2+ years, picking this up should be fairly straight forward. I expect the most dramatic new experience you'll have in this class will come with the UI/UX design portions, and event-driven applications, in addition to some implementation strategies and quirks built into C#.

The features borrowed from C++ include things like:

  • Qualifiers. Describing something as having a constant value is done using const instead of the Java equivalent final. Although there is a different qualifier used for arguments that aren't intended to be modified, which we'll cover later.
  • Passing by reference. Rather than using the & symbol like we did in C++ or the.. nothing we did in Java, C# has a ref qualifer used to describe something that's being passed by reference as opposed to passing by copy.
  • struct. These are basically less versatile versions of classes, with well defined attributes and methods that can be placed into public or private (the default, which is different than C++ structs) partitions of the structure. They cannot inherit or define a protected area, but can implement an interface, which we'll talk about later.
  • Operator overloading. Perhaps one of my favorite things about C++ finds inclusion with C# and that is the ability to provide programmer-defined implementations of how specific operators are used in relation to defined operands. This is particularly useful for the many classes we'll end up building in this course.
  • String variables are declared with a lowercase s (string), as the Good Lord intended.

And that's about it, actually. From Java, you'll recognize:

  • All of the code for your program is built inside of one or more classes, including a static void Main(string[] args) that will drive your program.
  • "foreach" loops, not to be confused with the for_each function from C++, although it will be functionally very similar. If you're unfamiliar with a "foreach" loop, they're effectively an easier way to implement the traditional "for" loop that is so regularly used in programming. Where you iterate from 0 to some maximum value, incrementing the index variable by one each time. Such as...

    for (int i = 0; i < MAX_SIZE; i++)
    cout << array[i] << endl;

    Instead, you would have...

    foreach (int i in array)
    System.out.println(i); // The Java equivalent of "cout << i << endl;"

    Where "i" would iteratively take on the value of each integer found in "array". This works for whatever data type you use for many containers, not just arrays. So you can use a "foreach" loop to iterate through vectors or sets.

  • Console Input/Output, or I/O as some scholars refer to it. Gone is the <</>> notation of C++ and what is used instead is a method from a class. In Java, this would be something like

    System.out.println("Hello world!");

    but in C#, it would look something like

    Console.WriteLine("Hello world!");

    "println" and "WriteLine" both have counterparts that do not put a newline character at the end: "print" and "Write".

  • Typecasting or converting from one data type to another. While in C++, you could do something as simple as cout << char(42) << endl; to print a * character, in Java (as well as in C#), you often have to call a method of a class (get ready to do this a lot in general). Such as

    int slacker = Convert.ToInt32(Console.ReadLine());

    Since the input read from the keyboard is of a string type by default. (Oh that's right, former CSCI 241 students of mine: slacker is making a comeback in a big way!!)

There will be other similiarities Java has with C# in regards to building and populating Frames or handling events, but we'll cover those more in detail as the course progresses.


Computing Resources

Windows users are encourged to use the Community Version of Visual Studios, as it will allow you to more easily save/access your projects from your own machine.

We will have access to Visual Studio 2017 through Citrix Workspace, which is already installed in the computer labs. This would be the more immediate connection, as compared to accessing VS2017 through AnywhereApps online. If you want a copy of your own:

  • This will take you directly to the download page (assuming that link still works.)
  • Install it. This make take some time. At some point, you will be asked for the Server Address. Put in anywhereapps.niu.edu. If this doesn't work, try https://anywhereapps.niu.edu instead.
To use it you will need to do the following:

  • Start Citrix Workspace.
  • You will be asked for Domain\User. Put in niunt\YourZ-ID. For example: niunt\Z1234567.
  • You will next need to put in your NIU password.
  • You should see a list of applications available to you. If Visual Studio 2017 is not there, click on the '+' at the left side. You will find a list of applications. Pick Visual Studio 2017.
The projects you create will be in a directory on a network drive (usually M:). You may want to keep backup copies on a USB drive.

You may want to obtain your own copy of Visual Studio and work on your own machine. Make sure they work correctly on Visual Studio 2017 on anywhereapps.

Lectures are going to regularly include code demonstrations, which will also function as a way to show how to use the various features of Visual Studio 2017 to develop your applications. Besides that, though, you're welcome to explore other online resources or tutorials in order to get more comfortable with the functionality available. One of the overarching themes of this class isn't to simply cover the mechanics of the C# language and the .NET Framework but to take a serious examination of how we go about approaching the problem of designing software solutions to problems. "Work smarter, not harder". — Michael Scott.