SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Introduction to C#




            FCIS
Summer training 2010, 1st year.

       Mohamed Samy
Aims of this course
 
     This course is an introduction to:
     
         The Event-driven programming model
     
         Writing GUI applications
     
         Object oriented programming
     
         The C# language
 
     While learning, these resources will help you:
     
         The lecture
     
         The labs
     
         The C# reference, released in parts
     
         ...but you need to practice, or all this will be
         worthless
             
                 Seriously :(
Tools
 
     This course uses Visual C# Express edition
     (which is a free download from Microsoft)
        −   http://www.microsoft.com/express/Windows/
New ideas about programming...

 
     Event-driven programming
 
     Object oriented programming
     
         Better for modeling
     
         Objects have state and behavior (attributes and
         methods).
     
         Classes, subclasses.
     
         Interface vs. implementation.
Event-driven programming

 Normal program       Event-driven program
 main( )              main( )
 {                    {
     doSubtask1( );       on event1 do { … }
     doSubtask2( );       on event2 do { … }
     doSubtask3( );       on event 3 do { … }
                          waitForEvents( );
 }
                      }
Event-driven programming

 Examples of events:
 
     Keyboard and mouse actions.
 
     Typing in a text box.
 
     Renaming a file.
 
     Arrival of data from the network.
 
     Adding an item to a collection.
 
     ...
OOP – Modeling the problem
 
     A word processor can use objects to represent:
        −   Paragraphs and pages
        −   Toolbars and dialogs
        −   Graphical objects
OOP – Modeling the problem
 
     A strategy game can use objects to represent:
        −   Units and buildings
        −   Teams
        −   Strategies and algorithms
OOP – Modeling the problem
 
     A desktop operating system can use objects
     to represent:
       −   Files and folders
       −   Hardware devices
What's an Object?

 
     An object has state and behavior.
 
     It represents state via attributes and behavior
     via methods.
 
     It has an interface and an internal
     implementation. Separating the interface from
     the implementation is encapsulation.
 
     Multiple object types can have the same
     interface, thus opening the door for
     polymorphism.
Objects and classes

    Classes describe the common attributes and
    behavior of related objects.

    You can do OOP without classes, but most
    OOP languages have them.

    A C# class has fields (data members, member
    variables) and methods (member functions).

    Fields and methods can be static or non-
    static.
       −   Non-static methods are also called instance methods or
           object methods. Same for fields.

    Classes can be superclasses or subclasses.
    Superclasses provide abstraction over types.
Let's do some programming

 
     "X owns Y" program
 
     The bouncing head program
What can be done with objects?

 
     Creating new objects
 
     Reading and writing fields
 
     Reading and writing properties
 
     Calling methods.
GUI without the designer
 using System.Windows.Forms;
 class Program
 {
     static void Main()
     {
         Form f;
         f = new Form();
         f.Text = "A simple program";
         f.SetBounds(20, 20, 400, 400);
         Application.Run(f); // for the main form only!!
     }
 }
Namespaces

    C# (actually, .net) program elements are
    organized into namespaces.

    To access an element in another namesoace,
    either use its full name nsName.elementName
    or import all the names from the namespace
    with using ...;

    To define your own namespaces, you can do
    this:
    
        namespace MyNS
    {
        class ABC { ... }
        class DEF { … }
    }
Instantiation

    The declaration
    Form f;
Tells the compiler the type of ' f ', but it does not
 create a new object.

    The only way to create an object is with new
    f = new Form( );

    New does 3 things
        −   Allocate memory for the object
        −   Initialize the object
        −   Return a reference to the object as the value of the new
            expression.
    
        Note: A reference is a number that's used to access
        an object. It's similar (but not the same) to pointers.
Setting properties

    The statement
   f.Text = "A simple program";
is the setting of a property (properties looks like
  member variables, but act like functions).

    You can also set member variables with the same
    syntax. Member variables work mostly like C++'s
    structs.
Setting properties / calling methods

    The statement
   f.SetBounds(20, 20, 400, 400);
Is a method call. In this case SetBounds is an
  instance method since it needs an object reference
  ' f ' to be called.

    The statement
   Application.Run(f);
Is calling the static method Run defined in the class
  Application. It is a static method since it doesn't
  need an object reference; but only a class name.
Terminology

           Related names                       Element

Instance                                        Object

Data member, Member variable,
                                                 Field
attribute

Member function                                 Method

Class method                                 Static method

Instance method, object method.            Non-static method

 Note
 While the names are conceptually related, they do not necessarily
 have the exact same meaning.
Next time...

 
     Reference types, Arrays, foreach...
 
     Graphics
 
     Handling KB events

 
     Remember to download the reference!

Contenu connexe

Tendances

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ FundamentalsSubhasis Nayak
 
Oop in c++ lecture 1
Oop in c++  lecture 1Oop in c++  lecture 1
Oop in c++ lecture 1zk75977
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop Kumar
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languagesppd1961
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented ProgrammingGamindu Udayanga
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IAjit Nayak
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementationthe_wumberlog
 
Reviewing OOP Design patterns
Reviewing OOP Design patternsReviewing OOP Design patterns
Reviewing OOP Design patternsOlivier Bacs
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesTushar B Kute
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Objectdkpawar
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#foreverredpb
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesDurgesh Singh
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending ClassesNilesh Dalvi
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - AbstractionMichael Heron
 

Tendances (20)

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
 
Oop in c++ lecture 1
Oop in c++  lecture 1Oop in c++  lecture 1
Oop in c++ lecture 1
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
 
Reviewing OOP Design patterns
Reviewing OOP Design patternsReviewing OOP Design patterns
Reviewing OOP Design patterns
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - Abstraction
 

En vedette

Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Abou Bakr Ashraf
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# IntroductionSiraj Memon
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To DotnetSAMIR BHOGAYTA
 
Csc153 chapter 07
Csc153 chapter 07Csc153 chapter 07
Csc153 chapter 07PCC
 
Csc153 chapter 04
Csc153 chapter 04Csc153 chapter 04
Csc153 chapter 04PCC
 
Csc253 chapter 09
Csc253 chapter 09Csc253 chapter 09
Csc253 chapter 09PCC
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Abou Bakr Ashraf
 
Csc153 chapter 02
Csc153 chapter 02Csc153 chapter 02
Csc153 chapter 02PCC
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Abou Bakr Ashraf
 
Csc153 chapter 01
Csc153 chapter 01Csc153 chapter 01
Csc153 chapter 01PCC
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introductionPeter Gfader
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp PresentationVishwa Mohan
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET ProgrammingKarthikeyan Mkr
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net frameworkThen Murugeshwari
 

En vedette (20)

Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
C# basics
 C# basics C# basics
C# basics
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
C# program structure
C# program structureC# program structure
C# program structure
 
Csc153 chapter 07
Csc153 chapter 07Csc153 chapter 07
Csc153 chapter 07
 
Csc153 chapter 04
Csc153 chapter 04Csc153 chapter 04
Csc153 chapter 04
 
Csc253 chapter 09
Csc253 chapter 09Csc253 chapter 09
Csc253 chapter 09
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 
Csc153 chapter 02
Csc153 chapter 02Csc153 chapter 02
Csc153 chapter 02
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1
 
Csc153 chapter 01
Csc153 chapter 01Csc153 chapter 01
Csc153 chapter 01
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introduction
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
C#.NET
C#.NETC#.NET
C#.NET
 
Microsoft C# programming basics
Microsoft C# programming basics  Microsoft C# programming basics
Microsoft C# programming basics
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET Programming
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 

Similaire à C# Summer course - Lecture 1

Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdfconceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdfSahajShrimal1
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.pptTigistTilahun1
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction paramisoft
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsSaurabh Narula
 
1 intro
1 intro1 intro
1 introabha48
 
Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script PatternsAllan Huang
 
CPP_,module2_1.pptx
CPP_,module2_1.pptxCPP_,module2_1.pptx
CPP_,module2_1.pptxAbhilashTom4
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentPython Ireland
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptBill Buchan
 

Similaire à C# Summer course - Lecture 1 (20)

Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdfconceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
 
Oop java
Oop javaOop java
Oop java
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
1 intro
1 intro1 intro
1 intro
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script Patterns
 
CPP_,module2_1.pptx
CPP_,module2_1.pptxCPP_,module2_1.pptx
CPP_,module2_1.pptx
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
 
Chapter1 introduction
Chapter1 introductionChapter1 introduction
Chapter1 introduction
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Bp301
Bp301Bp301
Bp301
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
 

Plus de mohamedsamyali

Computational thinking in Egypt
Computational thinking in EgyptComputational thinking in Egypt
Computational thinking in Egyptmohamedsamyali
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3mohamedsamyali
 
C# Summer course - Lecture 4
C# Summer course - Lecture 4C# Summer course - Lecture 4
C# Summer course - Lecture 4mohamedsamyali
 
Computer science department - a four page presentation
Computer science department - a four page presentationComputer science department - a four page presentation
Computer science department - a four page presentationmohamedsamyali
 
Presentation skills for Graduation projects
Presentation skills for Graduation projectsPresentation skills for Graduation projects
Presentation skills for Graduation projectsmohamedsamyali
 
Themes for graduation projects 2010
Themes for graduation projects   2010Themes for graduation projects   2010
Themes for graduation projects 2010mohamedsamyali
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic languagemohamedsamyali
 

Plus de mohamedsamyali (10)

Computational thinking in Egypt
Computational thinking in EgyptComputational thinking in Egypt
Computational thinking in Egypt
 
C++ syntax summary
C++ syntax summaryC++ syntax summary
C++ syntax summary
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3
 
C# Summer course - Lecture 4
C# Summer course - Lecture 4C# Summer course - Lecture 4
C# Summer course - Lecture 4
 
Computer science department - a four page presentation
Computer science department - a four page presentationComputer science department - a four page presentation
Computer science department - a four page presentation
 
Presentation skills for Graduation projects
Presentation skills for Graduation projectsPresentation skills for Graduation projects
Presentation skills for Graduation projects
 
Erlang session1
Erlang session1Erlang session1
Erlang session1
 
Erlang session2
Erlang session2Erlang session2
Erlang session2
 
Themes for graduation projects 2010
Themes for graduation projects   2010Themes for graduation projects   2010
Themes for graduation projects 2010
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic language
 

Dernier

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 

Dernier (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 

C# Summer course - Lecture 1

  • 1. Introduction to C# FCIS Summer training 2010, 1st year. Mohamed Samy
  • 2. Aims of this course  This course is an introduction to:  The Event-driven programming model  Writing GUI applications  Object oriented programming  The C# language  While learning, these resources will help you:  The lecture  The labs  The C# reference, released in parts  ...but you need to practice, or all this will be worthless  Seriously :(
  • 3. Tools  This course uses Visual C# Express edition (which is a free download from Microsoft) − http://www.microsoft.com/express/Windows/
  • 4. New ideas about programming...  Event-driven programming  Object oriented programming  Better for modeling  Objects have state and behavior (attributes and methods).  Classes, subclasses.  Interface vs. implementation.
  • 5. Event-driven programming Normal program Event-driven program main( ) main( ) { { doSubtask1( ); on event1 do { … } doSubtask2( ); on event2 do { … } doSubtask3( ); on event 3 do { … } waitForEvents( ); } }
  • 6. Event-driven programming Examples of events:  Keyboard and mouse actions.  Typing in a text box.  Renaming a file.  Arrival of data from the network.  Adding an item to a collection.  ...
  • 7. OOP – Modeling the problem  A word processor can use objects to represent: − Paragraphs and pages − Toolbars and dialogs − Graphical objects
  • 8. OOP – Modeling the problem  A strategy game can use objects to represent: − Units and buildings − Teams − Strategies and algorithms
  • 9. OOP – Modeling the problem  A desktop operating system can use objects to represent: − Files and folders − Hardware devices
  • 10. What's an Object?  An object has state and behavior.  It represents state via attributes and behavior via methods.  It has an interface and an internal implementation. Separating the interface from the implementation is encapsulation.  Multiple object types can have the same interface, thus opening the door for polymorphism.
  • 11. Objects and classes  Classes describe the common attributes and behavior of related objects.  You can do OOP without classes, but most OOP languages have them.  A C# class has fields (data members, member variables) and methods (member functions).  Fields and methods can be static or non- static. − Non-static methods are also called instance methods or object methods. Same for fields.  Classes can be superclasses or subclasses. Superclasses provide abstraction over types.
  • 12. Let's do some programming  "X owns Y" program  The bouncing head program
  • 13. What can be done with objects?  Creating new objects  Reading and writing fields  Reading and writing properties  Calling methods.
  • 14. GUI without the designer using System.Windows.Forms; class Program { static void Main() { Form f; f = new Form(); f.Text = "A simple program"; f.SetBounds(20, 20, 400, 400); Application.Run(f); // for the main form only!! } }
  • 15. Namespaces  C# (actually, .net) program elements are organized into namespaces.  To access an element in another namesoace, either use its full name nsName.elementName or import all the names from the namespace with using ...;  To define your own namespaces, you can do this:  namespace MyNS { class ABC { ... } class DEF { … } }
  • 16. Instantiation  The declaration Form f; Tells the compiler the type of ' f ', but it does not create a new object.  The only way to create an object is with new f = new Form( );  New does 3 things − Allocate memory for the object − Initialize the object − Return a reference to the object as the value of the new expression.  Note: A reference is a number that's used to access an object. It's similar (but not the same) to pointers.
  • 17. Setting properties  The statement f.Text = "A simple program"; is the setting of a property (properties looks like member variables, but act like functions).  You can also set member variables with the same syntax. Member variables work mostly like C++'s structs.
  • 18. Setting properties / calling methods  The statement f.SetBounds(20, 20, 400, 400); Is a method call. In this case SetBounds is an instance method since it needs an object reference ' f ' to be called.  The statement Application.Run(f); Is calling the static method Run defined in the class Application. It is a static method since it doesn't need an object reference; but only a class name.
  • 19. Terminology Related names Element Instance Object Data member, Member variable, Field attribute Member function Method Class method Static method Instance method, object method. Non-static method Note While the names are conceptually related, they do not necessarily have the exact same meaning.
  • 20. Next time...  Reference types, Arrays, foreach...  Graphics  Handling KB events  Remember to download the reference!