What you need to follow along
A Windows PC
The .NET package (Comes with Vista pre-installed, Need to install on XP)
The Microsoft Visual Studio IDE, free or pro, up to you.
A background in programming
Time, pleanty of time.
What you need to follow along
A Windows PC
The .NET package (Comes with Vista pre-installed, Need to install on XP)
The Microsoft Visual Studio IDE, free or pro, up to you.
A background in programming
Time, pleanty of time.
So, as i said before, We don’t compile into machine Code, we simply convert into IL and the CLR will run the IL.
If you want to view the IL, simply run ildasm.exe from the Visual Studio Command Prompt (In your start menu) and then you can select a file to view the IL for it, if you want to see the code check out reflector (Yes, you can convert it back to C#)
Don’t freak out just yet, i know anyone can see your source code, But you can use an obfuscator to make it hard to read by humans.
On other thoughts, if you want to freak out, do it now, but trust me as you understand the technology you will find that there are ways to reasonably protect your code.
Anyway, untill microsoft shows us something real with there Pheonix compiler, you are free to freak out, If a licensing string is in there chances are someone will find it and change it (But they used to do that with x86 code too right), But again this is 20 times easier, if you are going to distribute without obfuscation, why don’t you spare the guy some time downloading reflector and give him the source code too…
I have already told you about the .NET libraries right ? Base class libraries that come with .NET are organised into namespaces (And the same will apply to how you organise your software)
System, System.Data, System.IO, System.Drawing
The above are only a small sample of .NET namespaces. You will learn about the important namespaces as we go.
Before you can use anything from a library you will need to use the “using” keyword to include that thing in your software
using System;
So, when you write software for the .NET platofrm, you end with EXEs and DLLs right ? Yes you do but they will not run unless .NET or Mono or a certain platform is installed.
So, how are they organised ?
You can make a single file .NET program or a multi file one,
Single file assembly
If it is a single file assembly you have all your IL, and Metadata in that file, Metadata is devided into 2 parts.
File Metadata – tells the runtime (DLR) about your program, what platofrm it is targetting, what it uses et…
Manifest – Describes the assembly.
Multi File Assembly
Every file has it’s own metadata, and the main file of the assembly has the Manifest about all the files.
If you want to learn C#, you probably want to skip this, it has nothing that is important to you really, if you insist here you go.
A language that has a .NET compiler is a language where a compiler exists that can translate the language to IL rather than machine Code.
You probably already write one of these languages, (PHP is very popular and a .NET language…) see the list below
A#
APL
ASP.NET: ASM to IL
AsmL
ASP (Gotham)
Basic
-> VB .NET (Microsoft)
-> VB .NET (Mono)
BETA
Boo
BlueDragon
C
-> lcc
-> cscc
C#
-> C# (Microsoft)
-> C# (Mono)
Cw
C++ (Microsoft)
Cat
CIL
Cobol
-> NetCOBOL (Fujitsu)
-> Net Express (Micro Focus)
CQL
CULE.NET
E#
Eiffel
F#
Forth
Fortran
-> Fortran (Lahey)
-> Fortran (Silverfrost)
Haskell (VHS)
IronPython
Java
-> J# (Microsoft)
-> Java (IKVM .NET)
-> JNBridge
JScript .NET
Lego.NET
Lisp
-> DotLisp
-> IronScheme
-> L#
-> FOIL
leXico
LOLCODE
Lua.NET
M#
Mercury
Metaphor
MixNet
Mondrain
Nermerle
Oberon
Ook# .NET
OMeta#
Pan#
Pascal
-> Chrome
-> Delphi
-> Component Pascal
PerlNET
PHP
Prolog
Ruby
-> IronRuby
-> Ruby/.NET Bridge
-> Ruby.NET
Smalltalk
-> S#
-> #Smalltalk
-> Smalltalk and .NET
Scala
SML .NET
Spec#
Tachy
TickleSharp
Zonnon
Forget about the fancy names, i will describe stuff for you informally here, and i can add more information when you need it.
you probably already know what an interpreted language and a compiled language is right, the .NET platform is an interpreter for MSIL, when you compile your software you do not end up with machine code but rather IL (Intermediate Language Code), the .NET platform is a fancy name for the IL interpreter.
You may hear the following terms along the way, here is what they really means.
CLR – The actual IL interpreter
JIT – Just in Time compiler – The part of the interpreter that makes the binary that will execute on the machine, it is envoked when your software is running, the name is missleading a bit, but for now let us say it is like this.
Pre-Jitting – There is a nice tool that allows you to turn your software into Machine Code at installation time (NOT AT FACTORY), But don’t get too excited, it is not exactly like this, you still need .NET to run the software and posses pleanty of limitations.
CTS – Common Type System – All the types / Data types .NET supports
CLS – Common language Specification – A subset of CTS that is simply a set of all Types supported by any .NET language (Has to do with code in multiple higher languages)
Base class libraries – Libararies that ship with .NET.
As usual will come back to refine later, for now this is all you need to know.
You probably want my oppinion on if you should C#, Java or C++, since i have been coding C, C++ and now C# and know a bit about Java.
I have also investigated plenty before choosing C# over Java, here i will tell you about my findings.
The answer is – Go C# -
Reasoning
0- Although i love C++, why not know both and use both, i can always use my C++ programs in my C# programs
1- Better integration with Windows
2- Good tools, I love the MS studio IDE…
3- It is a spin on Java yes, that is certain, But how is that relevant ?
4- Microsoft released tools that translate Java into C#, so if you are looking to reuse Java code, YOU CAN.
5- Java does not allow you to use stuff written in other languages, C# does, and almost any popular language has a .NET variant
Ok, i do have concerns about people reversing my code since it ships in Intermediate Language, but really as you read you will realise that options are limited, and .NET is good compromise, you can make the harm much much milder with Obfuscators.
I will probably add to this later on.
I wanted somewhere to write my C# notes as i read it from 3 different books, Only one of them won me over to the .NET camp, I want to start by thanking Andrew Troelsen for the lovely Pro C# 2008 and the .NET 3.5 Platform, it is an excellent book, along with the extra chapters from the a-press website and two more books i am ready to code for the .NET 2.0 platform.
*Note, i am writing this after i read all three books and found myself going back and forth for the books*
I want to code for .NET 2.0 because of all the Windows XP (not everyone wants or has SP2 and not everyone wants a massive .NET download)
Organizing the website.
Although i should have installed a WIKI, i found this domain that is no longer useful for any post past 2008, and i found WordPress installed on it, Why waste more time, i will add pages to organize this content later… for now all i want is a place to write and come back to, a place for my notes where others can benefit.
Again i will add a page to organise the content very soon, then i will make it the front page, and after that you should be able to find your way regardless of the fact that this is blogging software.