0% found this document useful (0 votes)
22 views

Chapter 1

C# is an object-oriented programming language developed by Microsoft. This document provides an introduction to C# and Visual Studio, including the history and evolution of C# through its various versions. It describes key concepts like object-oriented programming, procedural programming, and programming languages. It also outlines features and capabilities introduced in each major version of C# from version 1.0 through the latest version 10.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Chapter 1

C# is an object-oriented programming language developed by Microsoft. This document provides an introduction to C# and Visual Studio, including the history and evolution of C# through its various versions. It describes key concepts like object-oriented programming, procedural programming, and programming languages. It also outlines features and capabilities introduced in each major version of C# from version 1.0 through the latest version 10.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 67

COMPUTER

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#

• An object-oriented language created by Microsoft for .NET.


• C# (pronounced “see sharp”) builds on some of the best features of the major
programming languages.
• It combines the power of C++ with the simplicity of Visual Basic and also borrows
much from Java. This results in a language that is easy to learn and use, robust
against errors, and enables rapid application development.
• All this is achieved without sacrificing much of the power or speed, when compared
to C++.
WHAT IS PROGRAMMING?
WHAT IS PROGRAMMING?

• The process of designing and building an executable computer program for


accomplishing a specific computing task. – Wikipedia
• The act of creating instructions for a computer to carry out.- David Joyner
(2016)
WHAT IS A PROGRAMMING
LANGUAGE?
WHAT IS ITS MAJOR FAMILIES?
PROGRAMMING LANGUAGE

• Programming languages allow programmers to code software.


• The three major families of languages are:
Machine languages
Assembly languages
High-Level languages
MACHINE LANGUAGES

• Comprised of 1s and 0s.


• The “native” language of a computer.
• Difficult to program.
• Example of code:
1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111
1110010 1101100 1100100
ASSEMBLY LANGUAGES

• Assembly languages are a step towards easier programming.


• Assembly languages are comprised of a set of elemental commands which are tied to a
specific processor.
• Assembly language code needs to be translated into machine language before the computer
processes it.
• Example of Code:
.data
num1 DW 1000h
num2 DW 2000h
HIGH-LEVEL LANGUAGES

• High-level languages represent a giant leap towards easier programming.


• The syntax of HL languages is similar to English.
• Example of Code:
print(“Hello World”) #Python PL
• Historically, we divide HL languages into two groups:
• Procedural Programming
• Object-Oriented Programming (OOP)
PROCEDURAL PROGRAMMING

• 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

• A programming paradigm based on the concept of "objects", which may


contain data, in the form of fields, often known as attributes; and code, in the
form of procedures, often known as methods.
PROCEDURAL VS OBJECT-ORIENTED
HISTORY OF C#
HISTORY OF C#

• 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#

• In January 1999, Anders Hejlsberg formed a team to build a new language at


the time called Cool, which stood for "C-like Object Oriented Language".
Microsoft had considered keeping the name "Cool" as the final name of the
language but chose not to do so for trademark reasons.
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

• It is intended to be simple, modern, general purpose, and object


oriented programming language.
EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET

• It should include strong type checking, array bound checking,


detection of attempts to use uninitialized variables, source code
portability and automatic garbage collection.
EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET

• It is intended for use in developing software components than can


take advantage of distributed environments.
EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET

• As programmer portability is very much important, especially for


those programmers already familiar with C & C++, C# is best
suitable.
EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET

• Provide support for internationalization, as it was very important.


EUROPEAN COMPUTER MANUFACTURERS
ASSOCIATION (ECMA)
DESIGN GOALS FOR C# .NET

• It is intended to be suitable for writing applications for both


hosted and embedded systems.
C# PROGRAMMING LANGUAGE

•A general-purpose, multi-paradigm programming language


encompassing strong typing, lexically scoped, imperative,
declarative, functional, generic, object-oriented, and component-
oriented.
• C#,like Java, is executed indirectly through an abstract
computer architecture called the CLR.
• CLR => Common Language Runtime.
• Abstract, but well defined.
• C# programs are compiled to an IL.
• Also called MSIL, CIL (Common Intermediate Language) or bytecode
C# VERSION 1.0

• 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

• Released November, 2020.


• Major features of C# 9
• Target-type new expressions.
• static anonymous functions
• Target-type conditional expressions
• Extension GetEnumerator() support for foreach loops
• Lambda expressions can declare discard parameters
• Attributes can be applied to local functions
C# VERSION 10

• Released November, 2021.

• 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

• Released November, 2022.


• Major features of C# 11
• Raw string literals
• Generic math support
• Generic attributes
• UTF-8 string literals
• Newlines in string interpolation expressions
• List patterns
• File-local types
• Required members
• Auto-default structs
• Pattern match Span<char> on a constant string
• Extended nameof scope
• Numeric IntPtr
• ref fields and scoped ref
.NET FRAMEWORK

• A software layer between Operating System and .Net compliant software


languages.
• It is a runtime environment or platform providing services and extensive set
of libraries to applications and developers.
• Microsoft started development on the .NET Framework in the late 1990s
originally under the name of Next Generation Windows Services (NGWS).
By late 2001 the first beta versions of .NET 1.0 were released.
.NET FRAMEWORK FUTURE INNOVATIONS
.NET FRAMEWORK VERSIONS
• .NET Framework 1.0 – 2002 for Windows 98, ME, NT 4.0, 2000, and XP
• .NET Framework 2.0 - 22 January 2006
• 64-bit computing support

• .NET Framework 3.0 - 21 November 2006


• includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008

• .NET Framework 3.5 - 19 November 2007


• .NET Framework 4.0 - 29 September 2008
• New Visual Basic .NET and C# language features

• .NET Framework 4.5 - 15 August 2012


• for Metro-style apps

• .NET Framework 4.6 - 12 November 2014


• higher performance and support for SSE2 and AVX2 instruction sets

• .NET Framework 4.7 - April 5, 2017


• was integrated into Windows 10 Creators Update

• .NET Framework 4.8 - April 18, 2019


• for high-resolution displays, performance updates, and security enhancements.
• .NET Framework 4.8.1 - September 2022
• Improved accessibility, which allows an application to provide an appropriate experience for users of Assistive Technology.
C# SUPPORTED
PROGRAMMING CODING
STYLE
PROGRAMMING CODING STYLE

• 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

• An Integrated Development Environment (IDE) from Microsoft.


• It is used to develop computer programs, as well as websites, web
apps, web services and mobile apps.
• It supports 36 different programming languages
• C, C++, C++/CLI, Visual Basic .NET, C#, F#, JavaScript, TypeScript,
XML, XSLT, HTML, and CSS.

• Community edition, is available free of charge.


• Installer download link: https://go.microsoft.com/fwlink/?
LinkId=532496&clcid=0x409&type=ISO
VISUAL STUDIO 2022 – SYSTEM REQUIREMENTS

• Supported Operating Systems


• Windows 11 minimum supported OS version or higher: Home, Pro, Pro Education, Pro for
Workstations, Enterprise, and Education.
• Windows 10 minimum supported OS version or higher: Home, Professional, Education, and Enterprise.
• Windows Server Core 2022
• Windows Server Core 2019
• Windows Server Core 2016
• Windows Server 2022: Standard and Datacenter.*
• Windows Server 2019: Standard and Datacenter.*
• Windows Server 2016: Standard and Datacenter.*
VISUAL STUDIO 2022 – SYSTEM REQUIREMENTS

• ARM64 or x64 processor; Quad-core or better recommended. ARM 32


processors are not supported.
• Minimum of 4 GB of RAM. Many factors impact resources used; we
recommend 16 GB RAM for typical professional solutions.
• Hard disk space: Minimum of 850 MB up to 210 GB of available space.
VISUAL STUDIO 2022
VISUAL STUDIO 2022 INSTALLATION
VISUAL STUDIO 2022 INSTALLATION

Wait for the installer to be


downloaded.
VISUAL STUDIO 2022 INSTALLATION

Select “.Net Desktop


Development”
VISUAL STUDIO 2022 INSTALLATION

Installation could took 10-


40 mins, depending on your
system.
VISUAL STUDIO 2022 INSTALLATION

• When VS start the sign in is required,


specially when using the community
edition.

• However, we could still skip this, but the


VS will expire in 30 days.
VISUAL STUDIO 2022 INSTALLATION

• We could select “Visual C#”


in the development Settings.

• We could also select a color


scheme
VISUAL STUDIO 2022 INSTALLATION
CREATE YOU FIRST WINDOWS FORM
APPLICATION

• Open Visual Studio.


• On the start window,
select Create a new project.
CREATE YOU FIRST WINDOWS FORM
APPLICATION

• On the Create a new


project window, select
the Windows Forms App (.NET
Framework) template for C#.
CREATE YOU FIRST WINDOWS FORM
APPLICATION

• In the Configure your new


project window, type or
enter HelloWorld in the Project
name box. Then, select Create.
• Visual Studio opens your new
project.
CREATE YOU FIRST WINDOWS FORM
APPLICATION

• 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

Solution Explorer - Lets you view, navigate,


and manage your code files. Solution
Explorer can help organize your code by
grouping the files into solutions and projects.
It displays all the objects that you are using
on your project including your forms,
datasets, reports, modules, references and
different resources.
VS2022 IDE

Properties - displays different


types of editing fields, depending
on the needs of a particular
property. These edit fields
include edit boxes, drop-down
lists, and links to custom editor
dialog boxes. Properties shown in
gray are read-only.
VS2022 IDE

Toolbox - The tool box


displays different visual
objects/tools that you can
use on your form.
VS2022 IDE

The editor window is


where you can edit
code or design a user
interface such as a
window with buttons
and text boxes.
COMMON CONTROL CONTROLS NAMING
PROPERTIES CONVENTION

• (Name) – name of the control. • TextBox – txt_


• Text – text or label of the control. • ComboBox – cmb_

• Size – width and height of the control. • Label – lbl_

• Font – Change font type, and font size. • Button – btn_

• Locked – lock the position of the control. • Radio – rb_

• Location – X and Y location in the form • Checkbox – chk_


of the control.
• Enabled – enable or disable the control Rule of thumb always create control
abbreviation 2 or 3 character followed by the
• TabIndex – the order of tab.
control purpose or desired name.

You might also like