SlideShare a Scribd company logo
1 of 6
Download to read offline
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

More Related Content

What's hot

Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 

What's hot (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
 

Viewers also liked

Rotation and Tessellation
Rotation and TessellationRotation and Tessellation
Rotation and Tessellation
Jeanette Murphy
 
Advanced Blogging
Advanced BloggingAdvanced Blogging
Advanced Blogging
mythicgroup
 
E learners presentation 2010
E learners presentation 2010E learners presentation 2010
E learners presentation 2010
Jeanette Murphy
 

Viewers also liked (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
 

Similar to 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-paper
Deepak Singh
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
Little Tukta Lita
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
Little Tukta Lita
 
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
Dr-archana-dhawan-bajaj
 
Boost.Interfaces
Boost.InterfacesBoost.Interfaces
Boost.Interfaces
melpon
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
voegtu
 

Similar to 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
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
Safe Software
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
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...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
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...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

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