SlideShare a Scribd company logo
1 of 42
Download to read offline
Introduction to Programming
Creating and Running
Your First C# Program
Svetlin Nakov
Technical Trainer
www.nakov.com
Software University
http://softuni.bg
2
1. What is Computer Programming?
2. Your First C# Program
3. What is C#?
4. What is .NET Framework?
5. What is Visual Studio?
 Compiling, Running and
Debugging C# Programs
6. What is MSDN Library?
Table of Contents
What is Computer Programming?
4
Computer programming: creating a sequence of
instructions to enable the computer to do something
Define: Computer Programming
Definition by Google
5
 Define a task / problem
 Plan your solution
 Find suitable algorithm / data structures to use
 Find suitable libraries / platforms / frameworks
 Write source code (step by step)
 Fix program errors (bugs)
 Install, configure and run the software
 Fix / improve the software over the time
Software Development Phases
= Specification
= Architecture / Design
= Implementation
= Testing & Debugging
= Deployment
= Maintenance
Your First C# Program
Sample C# program:
using System;
class HelloCSharp
{
static void Main()
{
Console.WriteLine("Hello, C#");
}
}
First Look at C#
7
C# Code – How It Works?
8
using System;
class HelloCSharp
{
static void Main()
{
Console.WriteLine("Hello, C#");
}
}
Include the standard .NET
namespace "System"
Define a class called
"HelloCSharp"
Define the Main()
method – the
program entry point
Print a text on the console by calling the
method "WriteLine" of the class "Console"
9
The C# Code Should Be Well Formatted
using System;
class HelloCSharp
{
static void Main()
{
Console.WriteLine("Hello, C#");
}
}
The { symbol should be
alone on a new line.
The block after the { symbol
should be indented by a TAB.
The } symbol should be
under the corresponding {.
Class names should use PascalCase
and start with a CAPITAL letter.
10
Example of Bad Code Formatting
using
System
;
class HelloCSharp {
static
void Main( ) { Console
. WriteLine ("Hello, C#" ) ;Console.
WriteLine ( "Hello again"
) ;}}
Such formatting makes the
source code unreadable
11
 C# is a modern programming language
 A syntax that allows to give instructions to the computer
 C# features:
 Extremely powerful
 Easy to learn
 Easy to read and understand
 Object-oriented
 Functional programming features
What is "C#"?
12
 A programming language
 C#
 Problem to solve
 IDE, compilers, SDK
 Visual Studio, .NET Framework SDK
 Set of useful standard classes
 Microsoft .NET Framework FCL
 Help documentation
 MSDN Library
What You Need to Program?
Your First C# Program
Live Demo
What is .NET
Framework?
15
 Environment for execution of .NET programs (CLR)
 Powerful library of classes (FCL)
 Programming model
 Common execution engine for many programming languages
 C#
 Visual Basic .NET
 Managed C++
 ... and many others
What is .NET Framework?
 The building blocks of .NET Framework
16
Inside .NET Framework
Operating System (Windows / Linux)
FCL
CLR
Languages
OS
Common Language Runtime (CLR) + DLR (for Dynamic Languages)
Base Class Library (BCL) – I/O, Threading, Collections, Strings, …
ADO.NET, Entity Framework, LINQ, XML (Data Tier)
ASP.NET
MVC, Web Forms,
Web API, SignalR
WCF, WWF (Communication / Workflow Tier)
WPF &
XAML
Windows
Store Apps
Windows
Forms
Silverlight,
WP7 / WP8
C# VB.NET Managed C++ F# Python Delphi …
17
 Common Language Runtime (CLR)
 Managed execution environment (virtual machine)
 Executes .NET applications
 Controls the execution process
 Automatic memory management (garbage collection)
 Programming languages integration
 Multiple versions support for assemblies
 Integrated type safety and security
CLR – The Heart of .NET Framework
CLR
18
 Framework Class Library (FCL)
 Provides basic classes for developers:
 Console applications
 Web applications and web services
 XAML, WPF, Silverlight rich-media applications
 Windows Forms and WPF GUI applications
 Windows Store applications
 Database applications
 Applications for mobile devices
Framework Class Library
What is Visual Studio?
20
 Visual Studio – Integrated Development Environment (IDE)
 Development tool that helps us to:
 Write code
 Design user interface
 Compile code
 Execute / test / debug applications
 Browse the help
 Manage project's files
Visual Studio
21
 Single tool for:
 Writing code in many languages (C#, VB.NET, Python, …)
 Using different technologies (Web Forms, MVC, WPF, EF, WCF, …)
 For different platforms (Win8, Silverlight, Windows Phone, …)
 Full integration of most development activities (coding,
compiling, testing, debugging, deployment, version control, ...)
 Very easy to use!
Benefits of Visual Studio
22
Visual Studio – Example
Visual Studio
Compiling, Running and Debugging C# Programs
24
1. File  New  Project ...
2. Choose Visual C#  Console Application
3. Choose project directory and name
Creating New Console Application
25
4. Visual Studio creates some source code for you
Creating New Console Application (2)
Namespace
not required
Class name
should be
changed
Most imports are
not required
File name
should be
changed
26
 The process of compiling includes:
 Syntactic checks
 Type safety checks
 Translation of the source code to lower level language (MSIL)
 Creating executable files (assemblies)
 You can start compilation by
 Using Build->Build Solution/Project
 Pressing [F6] or [Shift+Ctrl+B]
Compiling the Source Code
27
 The process of running application includes:
 Compiling (if project not compiled)
 Starting the application
 You can run application by:
 Using Debug->Start menu
 By pressing [F5] or [Ctrl+F5]
* NOTE: Not all types of projects are able to be started!
Running Programs
28
 The process of debugging application includes:
 Spotting an error
 Finding the lines of code that cause the error
 Fixing the error in the code
 Testing to check if the error is gone and no new
errors are introduced
 Iterative and continuous process
 Debuggers help a lot
Debugging The Code
29
 Visual Studio has a
built-in debugger
 It provides:
 Breakpoints
 Ability to trace the code
execution
 Ability to inspect
variables at runtime
Debugging in Visual Studio
Visual Studio
Compiling, Running and Debugging
C# Programs – Live Demo
Visual Studio
Blank Solution
Creating a Solution without any Projects
32
 A Visual Studio blank solution
 Solution with no projects in it
 Projects to be added later
 Why we need a blank
solution in Visual Studio?
 First create a blank solution for your homework
 Then create a project for each assignment from the homework
What Is a Blank Solution?
33
Creating a Blank Solution in Visual Studio
Visual Studio Blank Solution
Live Demo
What is MSDN
Library?
 Complete documentation of all classes and their functionality
 With descriptions of all methods, properties, events, etc.
 With code examples
 For all Microsoft technologies
 Related articles
 Library of samples
 MSDN Library is available at
msdn.microsoft.com/library
36
What is MSDN Library?
37
 Search in Google for certain class / method / property
 E.g.
 Or
 Or
 Use Visual Studio's built-in help system
 Press [F1] in Visual Studio in the code
 Browse http://msdn.microsoft.com
How to Use MSDN Library?
Press [F1] to view
the documentation
MSDN Library
Browsing the Documentation – Live Demo
39
 Programming: creating a sequence of instructions
(source code)
 C#: modern programming language, easy to learn
 C# programs: class + main method + code in it
 .NET Framework – a modern platform for
software development by Microsoft
 Visual Studio – powerful IDE for .NET developers:
write / compile / execute / debug code
 MSDN Library – the C# and .NET documentation
Summary
?
Introduction to Programming
http://softuni.bg/courses/csharp-basics
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
41
 Attribution: this work may contain portions from
 "Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license
 "C# Part I" course by Telerik Academy under CC-BY-NC-SA license
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.bg
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University @ YouTube
 youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg

More Related Content

What's hot

What's hot (20)

15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
 
Switch statement
Switch statementSwitch statement
Switch statement
 
Introduction to Algorithm
Introduction to AlgorithmIntroduction to Algorithm
Introduction to Algorithm
 
Iteration
IterationIteration
Iteration
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Arrays in Java
Arrays in Java Arrays in Java
Arrays in Java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 
Autoboxing and unboxing
Autoboxing and unboxingAutoboxing and unboxing
Autoboxing and unboxing
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
 
String in java
String in javaString in java
String in java
 
Big o notation
Big o notationBig o notation
Big o notation
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language Programming
 
Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithn
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
C# program structure
C# program structureC# program structure
C# program structure
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Huffman > Data Structures & Algorithums
Huffman > Data Structures & AlgorithumsHuffman > Data Structures & Algorithums
Huffman > Data Structures & Algorithums
 

Similar to 01. Introduction to Programming

LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxAOmaAli
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programmingStoian Kirov
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkAbdullahNadeem78
 
Csharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoCsharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoMamgmo Magnda
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop AppFajar Baskoro
 
Unit -II Introduction to visual programming.pdf
Unit -II Introduction to visual programming.pdfUnit -II Introduction to visual programming.pdf
Unit -II Introduction to visual programming.pdfUjwala Junghare
 
The seven pillars of aspnet
The seven pillars of aspnetThe seven pillars of aspnet
The seven pillars of aspnetNethaji Naidu
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0Antonio Chagoury
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfAliEndris3
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 

Similar to 01. Introduction to Programming (20)

LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptx
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programming
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net framework
 
Csharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoCsharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul Yao
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop App
 
Unit -II Introduction to visual programming.pdf
Unit -II Introduction to visual programming.pdfUnit -II Introduction to visual programming.pdf
Unit -II Introduction to visual programming.pdf
 
The seven pillars of aspnet
The seven pillars of aspnetThe seven pillars of aspnet
The seven pillars of aspnet
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
Intro1
Intro1Intro1
Intro1
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
 
W1.pptx
W1.pptxW1.pptx
W1.pptx
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
 
C# tutorial
C# tutorialC# tutorial
C# tutorial
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Visual Studio
Visual StudioVisual Studio
Visual Studio
 

More from Intro C# Book

17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversalIntro C# Book
 
Java Problem solving
Java Problem solving Java Problem solving
Java Problem solving Intro C# Book
 
21. Java High Quality Programming Code
21. Java High Quality Programming Code21. Java High Quality Programming Code
21. Java High Quality Programming CodeIntro C# Book
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism Intro C# Book
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstractionIntro C# Book
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritanceIntro C# Book
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexityIntro C# Book
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arraysIntro C# Book
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queuesIntro C# Book
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classesIntro C# Book
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processingIntro C# Book
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classesIntro C# Book
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and ClassesIntro C# Book
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and MapsIntro C# Book
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variablesIntro C# Book
 

More from Intro C# Book (20)

17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
Java Problem solving
Java Problem solving Java Problem solving
Java Problem solving
 
21. Java High Quality Programming Code
21. Java High Quality Programming Code21. Java High Quality Programming Code
21. Java High Quality Programming Code
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processing
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classes
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variables
 

Recently uploaded

LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfmchristianalwyn
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteMavein
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsRoxana Stingu
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpressssuser166378
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Shubham Pant
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilitiesalihassaah1994
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024Jan Löffler
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdfShreedeep Rayamajhi
 
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSedrianrheine
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSlesteraporado16
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxnaveenithkrishnan
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...APNIC
 

Recently uploaded (12)

LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a Website
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpress
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilities
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
 
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptx
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
 

01. Introduction to Programming

  • 1. Introduction to Programming Creating and Running Your First C# Program Svetlin Nakov Technical Trainer www.nakov.com Software University http://softuni.bg
  • 2. 2 1. What is Computer Programming? 2. Your First C# Program 3. What is C#? 4. What is .NET Framework? 5. What is Visual Studio?  Compiling, Running and Debugging C# Programs 6. What is MSDN Library? Table of Contents
  • 3. What is Computer Programming?
  • 4. 4 Computer programming: creating a sequence of instructions to enable the computer to do something Define: Computer Programming Definition by Google
  • 5. 5  Define a task / problem  Plan your solution  Find suitable algorithm / data structures to use  Find suitable libraries / platforms / frameworks  Write source code (step by step)  Fix program errors (bugs)  Install, configure and run the software  Fix / improve the software over the time Software Development Phases = Specification = Architecture / Design = Implementation = Testing & Debugging = Deployment = Maintenance
  • 6. Your First C# Program
  • 7. Sample C# program: using System; class HelloCSharp { static void Main() { Console.WriteLine("Hello, C#"); } } First Look at C# 7
  • 8. C# Code – How It Works? 8 using System; class HelloCSharp { static void Main() { Console.WriteLine("Hello, C#"); } } Include the standard .NET namespace "System" Define a class called "HelloCSharp" Define the Main() method – the program entry point Print a text on the console by calling the method "WriteLine" of the class "Console"
  • 9. 9 The C# Code Should Be Well Formatted using System; class HelloCSharp { static void Main() { Console.WriteLine("Hello, C#"); } } The { symbol should be alone on a new line. The block after the { symbol should be indented by a TAB. The } symbol should be under the corresponding {. Class names should use PascalCase and start with a CAPITAL letter.
  • 10. 10 Example of Bad Code Formatting using System ; class HelloCSharp { static void Main( ) { Console . WriteLine ("Hello, C#" ) ;Console. WriteLine ( "Hello again" ) ;}} Such formatting makes the source code unreadable
  • 11. 11  C# is a modern programming language  A syntax that allows to give instructions to the computer  C# features:  Extremely powerful  Easy to learn  Easy to read and understand  Object-oriented  Functional programming features What is "C#"?
  • 12. 12  A programming language  C#  Problem to solve  IDE, compilers, SDK  Visual Studio, .NET Framework SDK  Set of useful standard classes  Microsoft .NET Framework FCL  Help documentation  MSDN Library What You Need to Program?
  • 13. Your First C# Program Live Demo
  • 15. 15  Environment for execution of .NET programs (CLR)  Powerful library of classes (FCL)  Programming model  Common execution engine for many programming languages  C#  Visual Basic .NET  Managed C++  ... and many others What is .NET Framework?
  • 16.  The building blocks of .NET Framework 16 Inside .NET Framework Operating System (Windows / Linux) FCL CLR Languages OS Common Language Runtime (CLR) + DLR (for Dynamic Languages) Base Class Library (BCL) – I/O, Threading, Collections, Strings, … ADO.NET, Entity Framework, LINQ, XML (Data Tier) ASP.NET MVC, Web Forms, Web API, SignalR WCF, WWF (Communication / Workflow Tier) WPF & XAML Windows Store Apps Windows Forms Silverlight, WP7 / WP8 C# VB.NET Managed C++ F# Python Delphi …
  • 17. 17  Common Language Runtime (CLR)  Managed execution environment (virtual machine)  Executes .NET applications  Controls the execution process  Automatic memory management (garbage collection)  Programming languages integration  Multiple versions support for assemblies  Integrated type safety and security CLR – The Heart of .NET Framework CLR
  • 18. 18  Framework Class Library (FCL)  Provides basic classes for developers:  Console applications  Web applications and web services  XAML, WPF, Silverlight rich-media applications  Windows Forms and WPF GUI applications  Windows Store applications  Database applications  Applications for mobile devices Framework Class Library
  • 19. What is Visual Studio?
  • 20. 20  Visual Studio – Integrated Development Environment (IDE)  Development tool that helps us to:  Write code  Design user interface  Compile code  Execute / test / debug applications  Browse the help  Manage project's files Visual Studio
  • 21. 21  Single tool for:  Writing code in many languages (C#, VB.NET, Python, …)  Using different technologies (Web Forms, MVC, WPF, EF, WCF, …)  For different platforms (Win8, Silverlight, Windows Phone, …)  Full integration of most development activities (coding, compiling, testing, debugging, deployment, version control, ...)  Very easy to use! Benefits of Visual Studio
  • 23. Visual Studio Compiling, Running and Debugging C# Programs
  • 24. 24 1. File  New  Project ... 2. Choose Visual C#  Console Application 3. Choose project directory and name Creating New Console Application
  • 25. 25 4. Visual Studio creates some source code for you Creating New Console Application (2) Namespace not required Class name should be changed Most imports are not required File name should be changed
  • 26. 26  The process of compiling includes:  Syntactic checks  Type safety checks  Translation of the source code to lower level language (MSIL)  Creating executable files (assemblies)  You can start compilation by  Using Build->Build Solution/Project  Pressing [F6] or [Shift+Ctrl+B] Compiling the Source Code
  • 27. 27  The process of running application includes:  Compiling (if project not compiled)  Starting the application  You can run application by:  Using Debug->Start menu  By pressing [F5] or [Ctrl+F5] * NOTE: Not all types of projects are able to be started! Running Programs
  • 28. 28  The process of debugging application includes:  Spotting an error  Finding the lines of code that cause the error  Fixing the error in the code  Testing to check if the error is gone and no new errors are introduced  Iterative and continuous process  Debuggers help a lot Debugging The Code
  • 29. 29  Visual Studio has a built-in debugger  It provides:  Breakpoints  Ability to trace the code execution  Ability to inspect variables at runtime Debugging in Visual Studio
  • 30. Visual Studio Compiling, Running and Debugging C# Programs – Live Demo
  • 31. Visual Studio Blank Solution Creating a Solution without any Projects
  • 32. 32  A Visual Studio blank solution  Solution with no projects in it  Projects to be added later  Why we need a blank solution in Visual Studio?  First create a blank solution for your homework  Then create a project for each assignment from the homework What Is a Blank Solution?
  • 33. 33 Creating a Blank Solution in Visual Studio
  • 34. Visual Studio Blank Solution Live Demo
  • 36.  Complete documentation of all classes and their functionality  With descriptions of all methods, properties, events, etc.  With code examples  For all Microsoft technologies  Related articles  Library of samples  MSDN Library is available at msdn.microsoft.com/library 36 What is MSDN Library?
  • 37. 37  Search in Google for certain class / method / property  E.g.  Or  Or  Use Visual Studio's built-in help system  Press [F1] in Visual Studio in the code  Browse http://msdn.microsoft.com How to Use MSDN Library? Press [F1] to view the documentation
  • 38. MSDN Library Browsing the Documentation – Live Demo
  • 39. 39  Programming: creating a sequence of instructions (source code)  C#: modern programming language, easy to learn  C# programs: class + main method + code in it  .NET Framework – a modern platform for software development by Microsoft  Visual Studio – powerful IDE for .NET developers: write / compile / execute / debug code  MSDN Library – the C# and .NET documentation Summary
  • 41. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license 41  Attribution: this work may contain portions from  "Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license  "C# Part I" course by Telerik Academy under CC-BY-NC-SA license
  • 42. Free Trainings @ Software University  Software University Foundation – softuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University @ YouTube  youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bg