Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 16

C#

107-091
Welcome
John Morack
• Office L122
• Office Hours
– Wednesdays TBA
• Phone 691-5533
• Email jmorack@wctc.edu
Course Resources
• Required Text
– Programming C# 3.0 (5th Edition)
• Jesse Liberty & Donald Xie
• O’Reilly Publisher
- Software ( after week one) FREE!
- Email
- Student Network Space
- Local Data (C:)
Syllabus
Course requirements
Labs Graded

Backup disk
flash drive
Course Goals

1. Cover C# language features thoroughly


2. Use C# in WINFORM applications
3. Examine database interfacing with C#
4. Examine best practices
To keep focus on C# syntax we will begin with
console applications.
Here we go!!
//***************************************
// My first c# program
//**************************************
using system
public class First
{
static void Main()
{
System.Console.Writeline(“Hello World”);
}
}
Overview of C# and .NET

Terminology
• Source - Source Code Source File MyProg.cs
• Module - Compiled code into MSIL or IL
(Intermediate Language)
A single file program MyProg.exe
An Assembly with one file.
Building a program with notepad.
Use notepad and type in a program. (the source)
Save it with the extension .cs
From the command line compile the program using the
compiler csc.
C:\>csc myprog.cs
this produces the file myprog.exe
To run the program just type its name.
C:\>myprog.exe
//***************************************
// My first c# program
//**************************************
using System
public class First
{
static void Main()
{
System.Console.Writeline(“Hello World”);
}
}
Where does the execution begin?
All programs in .net must have a procedure or
subroutine named Main. Main is the entry point for
execution of the program.
Modules and Assemblies
• When you are building programs that use one or
more than one file you create something called an
assembly.
• Compiled source files are called modules.
• Modules can have extensions of .exe or .dll or
.netmodule ( all of these files will contain
compiled code)
• For a module to be able to execute it must be part
of an assembly. ( a compiled file with the
extension .exe is in an assembly by default)
Assembly Manifest
• The .exe file is the lead file of an assembly
and it contains the entry point.
• There can be only one .exe file in an
assembly
• The .exe file contains a list of files called
the manifest. If a file name is not in the
manifest, it cannot be used in the program.
What happens when you run a
program?
• The CLR (common language runtime) loads
the .exe file, translates it into machine
language in memory and transfers control to
the “Main function” in your program.

• The translation into machine code takes


place “just in time” to run. The CLR uses a
JIT compiler as its translator.
What happens when you run a
program?
• When your program needs a resource it is
the job of the CLR to get it. All files for a
program will reside in one folder with the
exception of shared modules.
• Libraries that are shared modules are found
in an area called the GAC (Global
Assembly Cache)
What files can be part of an
Assembly?
• .exe one and only one
• .netmodules or .dll files (which are code)
• Resource files such as images

You might also like