Chapter 1
Chapter 1
PROGRAMMING 2
C#
PREPARED BY: JOSHUA RELATORRES
INTRODUCTION TO C# AND VISUAL
STUDIO
Objectives:
• Differentiate Object Oriented Programming Approach to Procedural Programming
Approach.
• Understand why C# is develop.
• Enumerate the different C# versions.
• Learn the different supported programming style.
• Learn how to create project in visual studio.
• Enumerate all the common elements and components of Visual Studio 2015.
WHAT IS C#? (SEE SHARP)
C#
• The basic approach to code, writing sequences of instructions that are run by
the computer in a specified order.
• A programming paradigm, derived from structured programming, based upon
the concept of the procedure call. Procedures, also known as routines,
subroutines, or functions, simply contain a series of computational steps to be
carried out.
OBJECT-ORIENTED PROGRAMMING
• During the development of the .NET Framework, the class libraries were
originally written using a managed code compiler system called Simple
Managed C (SMC).
HISTORY OF C#
• By the time the .NET project was publicly announced at the Professional
Developers Conference on July 2000, the language had been renamed C#.
WHO IS THE ‘ECMA’?
EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET
• Release date January 2002 for .NET Framework 1.0 with an IDE Visual Studio .NET 2002.
• Major features of C# 1.0
• Classes
• Structs
• Interfaces
• Events
• Properties
• Delegates
• Expressions
• Statements
• Attributes
• C# version
C# VERSION 2.0
• Release date November 2005 for .NET Framework 2.0 with an IDE Visual Studio 2005.
• Major features of C# 2.0:
• Generics
• Partial types
• Anonymous methods
• Iterators
• Nullable value types
• Getter/setter separate accessibility
• Method group conversions (delegates)
• Co- and Contra-variance for delegates
• Static classes
• Delegate inference
C# VERSION 3.0
• Release date November 2007 for .NET Framework 2.0-3.5 with an IDE Visual Studio 2008-2010.
• Major features of C# 3.0:
• Implicitly typed local variables
• Object and collection initializers
• Auto-Implemented properties
• Anonymous types
• Extension methods
• Query expressions
• Lambda expression
• Expression trees
• Partial methods
C# VERSION 4.0
• Release date April 2010 for .NET Framework 4.0 with an IDE Visual Studio
2010.
• C# had moved the language firmly out from the shadow of Java.
• Major features of C# 4.0
• Dynamic binding
• Named and optional arguments
• Generic co- and contravariance
• Embedded interop types ("NoPIA")
C# VERSION 5.0
• Release date August 2012 for .NET Framework 4.5 with an IDE Visual
Studio 2012-2013.
• The last ECMA & ISO/IEC certified version.
• Major features of C# 5.0
• Asynchronous members
• If you have any I/O-bound needs (such as requesting data from a network or accessing a
database), you'll want to utilize asynchronous programming.
• Caller info attributes
• It has many uses in diagnostics and logging tasks.
C# VERSION 6.0
• Release date July 2015 for .NET Framework 4.6 with an IDE Visual Studio 2015.
• Can use the compiler as part of your programming efforts.
• Major features of C# 6.0
• Static imports
• Exception filters
• Auto-property initializers
• Expression bodied members
• Null propagator
• String interpolation
• Name of operator
• Index initializers
C# VERSION 7.0
• Release date March 2017 for .NET Framework 4.6.2 with an IDE Visual Studio 2017.
• Major features of C# 7.0.
• Inline out variable declaration
• Pattern matching
• Tuple types and tuple literals
• Deconstruction
• Local functions
• Digit separators
• Binary literals
• Ref returns and locals
• Generalized async return types
• Expression bodied constructors and finalizers
• Expression bodied getters and setters
• Throw can also be used as expression
C# VERSION 7.1
• Release date August 2017 for .NET Framework 4.7 with an IDE Visual
Studio 2017.
• Major features of C# 7.1
• Async main
• Default literal expressions
• Inferred tuple element names
C# VERSION 7.2
• Release date August 2017 for .NET Framework 4.7.1 with an IDE Visual
Studio 2017.
• Major features of C# 7.2
• Reference semantics with value types
• Non-trailing named arguments
• Leading underscores in numeric literals
• private protected access modifier
C# VERSION 7.3
• Release date May 2018 for .NET Framework 4.7.2 with an IDE Visual Studio
2017.
• Major features of C# 7.3
• Accessing fixed fields without pinning
• Reassigning ref local variables
• Using initializers on stackalloc arrays
• Using fixed statements with any type that supports a pattern
• Using additional generic constraints
C# VERSION 8.0
• Released September, 2019 for .NET Framework 4.8x IDE Visual Studio 2019.
• Major features of C# 8.0
• readonly struct members
• default interface members
• switch expressions
• Property, Tuple, and positional patterns
• using declarations
• static local functions
• Disposable ref struct
• Nullable reference types
• Indices and Ranges
• Null-coalescing assignment
C# VERSION 9
• Major features of C# 10
• Record structs
• Interpolated string handlers
• global using directives
• File-scoped namespace declaration
• Extended property patterns
• Allow const interpolated strings
• Record types can seal ToString()
• Allow both assignment and declaration in the same deconstruction
• Allow AsyncMethodBuilder attribute on methods
• CallerArgumentExpression attribute
C# VERSION 11
• It refers to a set of coding conventions, guidelines, and best practices that are
recommended and accepted within a particular programming language or
development community.
• These coding styles are supported because they help ensure consistency and
maintainability of code across different projects and among different
developers.
PROGRAMMING CODING STYLE
• Naming Conventions
• Indentation and Formatting
• Brace Placement
• Comments & Documentation
• Whitespace
• Consistency
• Refactoring and Clean Code
VISUAL STUDIO
• After you select your C# project template and name your file,
Visual Studio opens a form for you. A form is a Windows user
interface.
VS2022 IDE
Standard Tool Bar - The tool bar contains different shortcuts for opening/saving
projects as well as running your project once it is ready for debugging.
Status Bar - It appears on the bottom of the IDE. It displays the status of the
current operation. By default, it will display a “Ready” status but this will
change once your run the application.
VS2022 IDE