cs
cs
Introduce you to the craft of Deepen your knowledge of Build a solid proficiency in
software development various programming approaches reading and writing C#
Reference Materials
Advanced features of C#
GUI Programming
Midterm
Covers content taught in Part 1
Put together a robust piece of Details will be provided later in Leverages concepts learned in
non-trivial software the semester part 2
CRAFT OF SOFTWARE
DEVELOPMENT
What is a Craft
From Wikipedia: A craft or trade is a pastime
or an occupation that requires particular skills
and knowledge of skilled work. In a historical
sense, particularly the Middle Ages and
earlier, the term is usually applied to people
occupied in small scale production of goods,
or their maintenance, for example by tinkers.
https://learn.microsoft.com/en-us/dotnet/standard/assembly/
Ahead of Time (AOT)
Compilation
.NET Native compiles UWP apps directly to native code.
• See : https://learn.microsoft.com/en-
us/dotnet/core/deploying/native-aot/
https://learn.microsoft.com/en-us/dotnet/standard/clr
Unsafe Code and Pointers
• By default C# generates code that is verifiable
• C# supports pointers within unsafe contexts
• Unsafe code can only be used within unsafe blocks
within unsafe projects.
• Best to only use within projects designed for
interfacing with low-level code.
• Not necessary for high-performance code.
Source Code Generation
• C# doesn’t have a macro pre-processor but supports a few directives for
conditional compilation
• Tool-chain supports compile-time source generators
C# Versions: a new one every 2-3 years
• C# 1.0 – 2002 a nice little language
• C# 2.0 – 2005 generics: now we are talking
• C# 3.0 – 2007 lambda: WOW!
• C# 4.0 – 2010 dynamic keyword
• C# 5.0 – 2012 async / await (important, but took awhile to Grok)
• C# 6.0 – 2015 lots of syntactic sugar
• C# 7.0 – 2017 tuples and deconstruction
Wait, what??
• C# 7.1 – 2017
• C# 7.2 – 2017
• C# 7.3 – 2018
• C# 8.0 – 2018
• C# 9.0 – 2020
• C# 10.0 – 2021
• C# 11.0 – 2022
.NET Runtime and Default C# Language
.NET Standard 2.0 (Most Portable)
Targets .NET Framework since
4.6.2 and Unity 2018.1, as well
as other .NET
implementations.
• C# is garbage collected
• C# produced verifiable byte code which is compiled “just in time” (JIT)
• C# supports introspection, reflection, and run-time code generation
• In C# classes have different semantics than structs
• C# pointer types and operations are allowed, but only in unsafe contexts
• C# strings and arrays are classes
• C# supports only single inheritance, but has interfaces
Interfaces with
Safe and well- Garbage
Statically typed extension
defined collected
methods
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.
Source files
Organization • Using declarations
• Zero or one namespace
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/language-
reference/builtin-types/built-in-types
Boxing