Cs321 Winter 2023 Lecture 1
Cs321 Winter 2023 Lecture 1
Emphasis on hands-on
assignments culminating in a
final project.
Goals
Introduce you to the craft Deepen your knowledge of Build a solid proficiency in
of software development various programming reading and writing C#
approaches
Reference Materials
• OfficialC# Language Reference:
https://learn.microsoft.com/en-us/dotnet/csha
rp/language-reference
• Supplemental reading:
“C# In Depth Fourth Edition” by Jon Skeet
• Notes posted to GitHub at:
https://github.com/cdiggins/cs321
Course Evaluation
Advanced features of C#
GUI Programming
Midterm
Covers content taught in Part 1
https://learn.microsoft.com/en-us/dotnet/standard/ass
embly/
Ahead of Time (AOT)
Compilation
.NET Native compiles UWP apps directly to
native code.
• See :
https://learn.microsoft.com/en-us/dotnet/core/d
eploying/native-aot/
Interfaces
Statically with Safe and Garbage
typed extension well-defined collected
methods
Good
High quality Excellent Good
interoperabil
libraries tooling performance
ity
ELEMENTS OF CODE
A refresher using C#
Key Elements of a Program
Expressions Variables
Data Types
•A data type is a category of data
values. As a programmer you can
define new types using class, struct,
interface, and enum declarations.
• Unlikefunctions in mathematics,
they don't have to have a return
value and may cause side-effects
to happen
Statements
•A statement is a unit of code that conceptually represents a single
action. Statements may be compound, consisting of embedded
statements, or are simple and terminated with the ';' character.
• Some common examples of simple statements include:
Source files
Organizati • Using declarations
• Zero or one namespace
on of a C# Namespaces
Types
• Contain static and/or instance members
• Always in one namespace
• But may be split across files
Classes
Structs
Kinds of
Interfaces
Types
Enums
Delegates
Reference Types
• In C# classes are always allocated on the heap
• Unlike C++ their memory address can change.
• Means that in unsafe mode you have to “pin” pointers
• This prevents the GC from moving or reclaiming the memory
• Interfaces are also reference types
• All reference types inherit from System.Object
Value Types
• Most built-in types in C# are value types.
• Value types are defined in C# using the “struct” keyword
• This
means that they are defined on the stack and have copy-by-
value semantics
• Value types cannot inherit from other types
Built-in Types
https://learn.microsoft.com/en-us/dotnet/csharp/lan
guage-reference/builtin-types/built-in-types
Boxing