SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
The C# Language




                          Johan Franzén




C# – Overview

                Panel 1                   Panel 2

  Object Oriented (similar to Java)

  Appeared in 2001

  .NET Platform (VB.NET, J#, Managed C++ and more)

  Microsoft Windows

  Linux and Mac OS X with the mono project




                                                     1
C# – Common Language Infrastructure

               Panel 1         Panel 2




C# – Hello World

                               Panel 2

  using System;

  class Hello
  {
     static void Main() {
        Console.WriteLine(quot;Hello
        Console.WriteLine(quot;Hello worldquot;);
     }
  }




                                            2
C# – Data types

  int                                           Panel 2

  float
  string
  byte
  bool
  .
  .
  .

  float fValue = 2.0f;
  double dValue = 2.0;

  bool bValue = 5 (incorrect)




C# – Value Types and Reference Types

                       Panel 1                  Panel 2

  Value Types                                Value Type
                                             Point is a Struct
  By Value (copy)                            Point p1 = new Point();
                                             Point p2 = p1;
  int, float, … , Point, Vector2 (structs)
                                             (p2 is a copy of p1)
  Reference Types
  By Reference (reference)
                                             Reference Type
  Classes
                                             Person is a Class
                                             Person p1 = new Person();
                                                             Person();
                                             Person p2 = p1;

                                             (p2 points to the same
                                             object as p1)




                                                                         3
C# – Array & List

   Array (fixed size)

     int[]
     int[] myArray = new int[10];
                         int[10];

     myArray[2]
     myArray[2] = 3;




   List (can grow)

     List<int>
     List<int> myList = new List<int>();
                            List<int>();

     myList.Add(3);
     myList.Add(3);

     int myValue = myList[0];
                   myList[0];




C# – Iteration

   Standard for loop

      o
     for( t              y st Cou tt;
                        myList.Count;
     for(int i = 0; i < myList.Count; i++) {
                                         )
        Console.WriteLine(myList[
        Console.WriteLine(myList[i]);
     }



   foreach loop

     foreach(
     foreach(int value in myList) {
                          myList)
        Console.WriteLine( l )
        Console.WriteLine(value);
        C    l W it Li (value);
     }




                                               4
C# – get/set methods

   Java           Panel 1
   ------------------------------------------------
   class Person {
      private int age;

     public int getAge() { return age; }
                getAge()

     public void setAge(int value) {
                  setAge(
        if(age
        if(age >= 0)
           age = value;
     }
   }
   ------------------------------------------------
   Person p = new Person();
                  Person();
   p.setAge(20);
   p.setAge(20);
   int age = p.getAge();
             p.getAge();




C# – Properties

   C#             Panel 1           Panel 2
   ------------------------------------------------
   class Person {
      private int age;

     public int Age {
        get { return age; }
        set {
           if(age
           if(age >= 0)
              age = value;
                    value;
        }
     }
   }
   ------------------------------------------------
   Person p = new Person();
                  Person();
   p.Age = 20;
   int age = p.Age;
             p.Age;




                                                      5
ACTION




         6

Contenu connexe

Tendances

C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13Chris Ohk
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...James Titcumb
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust languageGines Espada
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in goYusuke Kita
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQLvikram mahendra
 

Tendances (20)

Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
C programs
C programsC programs
C programs
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
cosc 281 hw2
cosc 281 hw2cosc 281 hw2
cosc 281 hw2
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...
Mirror, mirror on the wall - Building a new PHP reflection library (Nomad PHP...
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust language
 
Elf文件解析
Elf文件解析Elf文件解析
Elf文件解析
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
week-20x
week-20xweek-20x
week-20x
 

En vedette

Rotation and Tessellation
Rotation and TessellationRotation and Tessellation
Rotation and TessellationJeanette Murphy
 
Stpm Pam Kertas2 Set2
Stpm Pam Kertas2 Set2Stpm Pam Kertas2 Set2
Stpm Pam Kertas2 Set2Kay Aniza
 
Skema Bm Kertas1 Set2
Skema Bm Kertas1 Set2Skema Bm Kertas1 Set2
Skema Bm Kertas1 Set2Kay Aniza
 
Meteor is Coming
Meteor is ComingMeteor is Coming
Meteor is ComingDaniel Teng
 
Advanced Blogging
Advanced BloggingAdvanced Blogging
Advanced Bloggingmythicgroup
 
Análisis exergético de sistemas industriales de aire comprimido
Análisis exergético de sistemas industriales de aire comprimidoAnálisis exergético de sistemas industriales de aire comprimido
Análisis exergético de sistemas industriales de aire comprimidoCarlos Alderetes
 
Smc073 11 april 2012 Vught
Smc073 11 april 2012 VughtSmc073 11 april 2012 Vught
Smc073 11 april 2012 VughtBart Brouwers
 
Management Final Project Fall 2008
Management Final Project Fall 2008Management Final Project Fall 2008
Management Final Project Fall 2008lat886
 
LambdaDay: Backbone.js
LambdaDay: Backbone.jsLambdaDay: Backbone.js
LambdaDay: Backbone.jsGiovanni Bassi
 
Zipmark product and market overview
Zipmark product and market overviewZipmark product and market overview
Zipmark product and market overviewJayastu Bhattacharya
 
E learners presentation 2010
E learners presentation 2010E learners presentation 2010
E learners presentation 2010Jeanette Murphy
 

En vedette (20)

Mobile Development
Mobile DevelopmentMobile Development
Mobile Development
 
Corei7
Corei7Corei7
Corei7
 
BDD no mundo real
BDD no mundo realBDD no mundo real
BDD no mundo real
 
Rotation and Tessellation
Rotation and TessellationRotation and Tessellation
Rotation and Tessellation
 
Stpm Pam Kertas2 Set2
Stpm Pam Kertas2 Set2Stpm Pam Kertas2 Set2
Stpm Pam Kertas2 Set2
 
Skema Bm Kertas1 Set2
Skema Bm Kertas1 Set2Skema Bm Kertas1 Set2
Skema Bm Kertas1 Set2
 
Meteor is Coming
Meteor is ComingMeteor is Coming
Meteor is Coming
 
Advanced Blogging
Advanced BloggingAdvanced Blogging
Advanced Blogging
 
Puertos De Comunicacion
Puertos De ComunicacionPuertos De Comunicacion
Puertos De Comunicacion
 
Análisis exergético de sistemas industriales de aire comprimido
Análisis exergético de sistemas industriales de aire comprimidoAnálisis exergético de sistemas industriales de aire comprimido
Análisis exergético de sistemas industriales de aire comprimido
 
Scavenger Hunt Collage
Scavenger Hunt CollageScavenger Hunt Collage
Scavenger Hunt Collage
 
Smc073 11 april 2012 Vught
Smc073 11 april 2012 VughtSmc073 11 april 2012 Vught
Smc073 11 april 2012 Vught
 
Moss Week 12 Final With Answers
Moss   Week 12   Final   With AnswersMoss   Week 12   Final   With Answers
Moss Week 12 Final With Answers
 
Wood
WoodWood
Wood
 
side_face samples
side_face samplesside_face samples
side_face samples
 
911 Jour 1
911  Jour 1911  Jour 1
911 Jour 1
 
Management Final Project Fall 2008
Management Final Project Fall 2008Management Final Project Fall 2008
Management Final Project Fall 2008
 
LambdaDay: Backbone.js
LambdaDay: Backbone.jsLambdaDay: Backbone.js
LambdaDay: Backbone.js
 
Zipmark product and market overview
Zipmark product and market overviewZipmark product and market overview
Zipmark product and market overview
 
E learners presentation 2010
E learners presentation 2010E learners presentation 2010
E learners presentation 2010
 

Similaire à C Sharp Lecture Johan Franzen

Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
Lecture 4: Data Types
Lecture 4: Data TypesLecture 4: Data Types
Lecture 4: Data TypesEelco Visser
 
C# Summer course - Lecture 2
C# Summer course - Lecture 2C# Summer course - Lecture 2
C# Summer course - Lecture 2mohamedsamyali
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr-archana-dhawan-bajaj
 
Boost.Interfaces
Boost.InterfacesBoost.Interfaces
Boost.Interfacesmelpon
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL乐群 陈
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Lies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerLies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerGarth Gilmour
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 

Similaire à C Sharp Lecture Johan Franzen (20)

TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
C++11
C++11C++11
C++11
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
Lezione03
Lezione03Lezione03
Lezione03
 
Lezione03
Lezione03Lezione03
Lezione03
 
Lecture 4: Data Types
Lecture 4: Data TypesLecture 4: Data Types
Lecture 4: Data Types
 
C#
C#C#
C#
 
C# Summer course - Lecture 2
C# Summer course - Lecture 2C# Summer course - Lecture 2
C# Summer course - Lecture 2
 
Python tour
Python tourPython tour
Python tour
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Why Learn Python?
Why Learn Python?Why Learn Python?
Why Learn Python?
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
Boost.Interfaces
Boost.InterfacesBoost.Interfaces
Boost.Interfaces
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Lies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerLies Told By The Kotlin Compiler
Lies Told By The Kotlin Compiler
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

C Sharp Lecture Johan Franzen

  • 1. The C# Language Johan Franzén C# – Overview Panel 1 Panel 2 Object Oriented (similar to Java) Appeared in 2001 .NET Platform (VB.NET, J#, Managed C++ and more) Microsoft Windows Linux and Mac OS X with the mono project 1
  • 2. C# – Common Language Infrastructure Panel 1 Panel 2 C# – Hello World Panel 2 using System; class Hello { static void Main() { Console.WriteLine(quot;Hello Console.WriteLine(quot;Hello worldquot;); } } 2
  • 3. C# – Data types int Panel 2 float string byte bool . . . float fValue = 2.0f; double dValue = 2.0; bool bValue = 5 (incorrect) C# – Value Types and Reference Types Panel 1 Panel 2 Value Types Value Type Point is a Struct By Value (copy) Point p1 = new Point(); Point p2 = p1; int, float, … , Point, Vector2 (structs) (p2 is a copy of p1) Reference Types By Reference (reference) Reference Type Classes Person is a Class Person p1 = new Person(); Person(); Person p2 = p1; (p2 points to the same object as p1) 3
  • 4. C# – Array & List Array (fixed size) int[] int[] myArray = new int[10]; int[10]; myArray[2] myArray[2] = 3; List (can grow) List<int> List<int> myList = new List<int>(); List<int>(); myList.Add(3); myList.Add(3); int myValue = myList[0]; myList[0]; C# – Iteration Standard for loop o for( t y st Cou tt; myList.Count; for(int i = 0; i < myList.Count; i++) { ) Console.WriteLine(myList[ Console.WriteLine(myList[i]); } foreach loop foreach( foreach(int value in myList) { myList) Console.WriteLine( l ) Console.WriteLine(value); C l W it Li (value); } 4
  • 5. C# – get/set methods Java Panel 1 ------------------------------------------------ class Person { private int age; public int getAge() { return age; } getAge() public void setAge(int value) { setAge( if(age if(age >= 0) age = value; } } ------------------------------------------------ Person p = new Person(); Person(); p.setAge(20); p.setAge(20); int age = p.getAge(); p.getAge(); C# – Properties C# Panel 1 Panel 2 ------------------------------------------------ class Person { private int age; public int Age { get { return age; } set { if(age if(age >= 0) age = value; value; } } } ------------------------------------------------ Person p = new Person(); Person(); p.Age = 20; int age = p.Age; p.Age; 5
  • 6. ACTION 6