[ Home | Syllabus | Course Notes | Assignments | Search]
A simple c# program (you can start here)
(This symbol is a noteworthy feature of the program - sometimes it references a footnote (if you click on it), footnotes appear after the program separated by a rainbow line)
F1: the top level namespace in .NET
F2: for "console" applications, this is where the program starts
F3: "Console" is in "system" like "cout" in C++
You can either write the program in your favorite text editor, or copy the "hello" program from the web site here
To compile, start a command prompt window
If you have installed the .NET framework from the textbook, your environment variables should be set for any command promprt window (start/run/cmd)
If you install visual studio.net, you need to run "Visual Studio .NET Command Prompt" (start/All Programs/Microsoft Visual Studio .NET/Visual Studio .Net Tools/Visual Studio .NET Command Prompt)
cd to the directory containing the program
compile the program - csc hello.cs
Now run it
To run this program using visual studio .net:
Start Visual Studio .Net
Select "New Project" (from Start Page or "File/New/Project"
In the resulting Dialog Box choose "Visual C# Project" and "Windows Application", select the appropriate Location and Project name.
Select "OK"
You can either add an existing file to the project or create a new one. Let's do it both ways:
To add an existing file, select "Project/Add Existing Item" then navigate to the location of that item to Open it
To add a new file, select
"Project/Add New Item" and select "Class"- you can
change the name of the source file at this time.
After selecting "Open" in the above dialog, you will get a
skeleton class shown here
You can now edit this skeleton (I just added the function
"Main" from above, leaving the constructor as is
Now build the solution ("Build/Build Solution")
Assuming everything compiles OK, you can run the program ("Debug/Start without Debugging"), you should see the result
"Main" is a static method
And there is a constructor (".ctor")
Double Click the Manifest to get
Two assemblies
One Module
Hash code
public key token
Unique ID (MVID)
Double click "Main" gives the Common Intermediate Language code
Entrypoint
ldstr - loads string into function calling stack - guess
call - information for a loader (needs function signature for overload differentiation - guess)
Although an admittedly simple program - it is a good start for some experimenting.
What might be some interesting ideas to try out? (good questions lead to good science)
Verify stack architecture. How to verify?
Verify overload information. How?
Learn more about WriteLine, How?
Learn how to get input, How?
Explore the "Console" class, How?
Add other variables to write out. What would be informative?