SlideShare a Scribd company logo
1 of 23
Niku Academy
What’s New In C#
NIKU
ACADEMY
A Division Of Niku SoftwareCall Niku Software 9768264140 1
Niku AcademyCall Niku Software 9768264140 2
C# Genealogy
Fortran Algol 68 C C++ C#
Cobol
Eiffel
JavaAda 95PL/I Pascal
Elementary
Procedural
Advanced
Procedural
Special
Procedural
Object
Oriented
Advanced
Object
Oriented
Ada 83
Niku AcademyCall Niku Software 9768264140 3
C# And .Net
 Languages like C# are not isolated entities
 They interoperate in two ways:
 By being part of a system written in more than one
language
 By accessing services and operating on a distributed
environment
 Requires support from run time:
 .Net and the Common Language Runtime
 .Net is many things, in particular binary object
access
 C# interoperates with .Net
Niku AcademyCall Niku Software 9768264140 4
The Simple Stuff
 Most of C# is pretty similar to languages you are
used to:
 Declarations
 Expressions
 Assignment and control statements
 Other elements are quite similar:
 Classes
 Functions
 Polymorphism
Niku AcademyCall Niku Software 9768264140 5
Major Topics To Discuss
 Identifier scope system—namespaces
 Type system
 Memory system and pointers
 Execution time environment
 Threads
 Exceptions
 Interfaces
Niku AcademyCall Niku Software 9768264140 6
Namespaces
Namespace CS415
Class A
Class B
Class C
 Permits isolation of names
 Can be nested
 Access via fully qualified
names
Namespace CS340
Class A
Class B
Class C
CS415.A…
CS340.A…
Niku AcademyCall Niku Software 9768264140 7
Type System
 Type should be consistent:
 Predefined and user-defined
 All C# types derive from System.Object
 Single rooted hierarchy
 Provides four standard methods:
 bool Equals
 int GetHashCode
 Type GetType
 String ToString
These don’t necessarily
mean what you think
Same object (ref) or same value (val)
Retrieve object type (reflection)
Retrieve object type (default)
Niku AcademyCall Niku Software 9768264140 8
Types Of Types
 Value types and reference types
 Value types:
 Program variables have a value
 Space allocated on stack
 Reference types:
 Program variable is just a reference
 Allocated space on stack
 Reference is a “type-safe” pointer
 Data space allocated on heap
Niku AcademyCall Niku Software 9768264140 9
Value vs. Reference
 Note the “special” status of primitive types
System.Int32 myInt = 42;
System.String myStr = “Hello World”;
Circle c;
c = new Circle(...);
42
address “Hello World”
Stack Heap
myStr
myInt
address Circle objectc
Be careful
with
deallocation
of the space
Niku AcademyCall Niku Software 9768264140 10
Boxing And Unboxing
 Conversion between value variable and
reference variable
System.Int32 myInt = 42;
object o = myInt;
int ymInt = (int)o;
42
o 42
Stack Heap
Boxed
myInt
object o
myInt
Niku AcademyCall Niku Software 9768264140 11
The Role Of A Type System
 What do we need from a type system?
 Types across languages:
 Consistency
 Compatibility
 Type safety:
 Checking for meaningful statements
 Add “speed” to “distance”?
 C# vs Ada
Niku AcademyCall Niku Software 9768264140 12
Memory Layout
Stack Heap
Garbage CollectorFunction Call & Return
Pointers
f() g() h() k()
f calls g, g calls h, h calls k
P*
Niku AcademyCall Niku Software 9768264140 13
C# Memory Management
 Static vs. dynamic
 Dynamic storage—stack and heap
 Stack (Dynamic):
 Managed algorithmically by implementation of
function calls
 Heap (Dynamic)
 Mostly managed by system
 Provision for management by programmer
Niku AcademyCall Niku Software 9768264140 14
C# Memory Management
 Allocation using new
 Deallocation by Garbage Collection
 Garbage collection:
 Tracks objects that are accessible
 Frees storage associated with objects that are
inaccessible
 Garbage collector is a system provided service that
runs periodically
 Deals with fragmentation
Niku AcademyCall Niku Software 9768264140 15
Garbage Collector Pros & Cons
 Pros:
 Programmer does not have to implement
 Memory management done right
 Cons:
 No guarantee when it runs, hence no control
 Takes processor resources
 Does not delete storage if it is still reachable even if
you don’t want it…
 Memory leaks can (and do) still occur
Niku AcademyCall Niku Software 9768264140 16
Some Specifics of C#
 Object destruction via Object.Finalize:
 Inherited from Object type
 Override to destroy object as desired
 Garbage collector available via GC class:
 Runs via separate thread
 Various methods available for access
 E.g., GC.collect()
 Pointers—yes, they are provided:
 Syntax like C++, code marked unsafe
 Objects managed by GC or user—pinned
Object
cannot be
moved
Niku AcademyCall Niku Software 9768264140 17
Traditional Compilation
Source
Program
Compiler
Object
Program
Linkage
Editor
Object
Program
Loader
Binary
Program
Machine
Instructions For
Specific Target
Object Code
Libraries
Relocatable
Relocatable
Not
Relocatable
Dynamic
Linking
Static
Linking
Niku AcademyCall Niku Software 9768264140 18
More Flexible Compilation
Source
Program
Compiler
Microsoft
Intermediate
Language (MSIL)
Program
TARGET
Run-time Support System
Machine
Instructions
For Multiple
Targets
TARGET
Run-time Support System
Interpreter Just-in-Time (JiT) Comp
Niku AcademyCall Niku Software 9768264140 19
Concurrency
 Threads vs. processes/tasks
 C# supports threads
Thread Thread Thread
Thread
Data
Communication
Who is
running
and when?
What exactly
are the
problems
here?
Niku AcademyCall Niku Software 9768264140 20
C# Threads
 System.Threading namespace
 Facilities include:
 Thread creation, destruction
 Child thread management, e.g. join()
 Thread scheduling, priority, timing
 Synchronization:
 Monitors
 Semphores (mutex class)
 Lock—serialization of statement block
Niku AcademyCall Niku Software 9768264140 21
Exceptions
 Why do we need exceptions?
 How should they be made available in programming
languages?
 What benefits do they provide?
 What problems could they cause for us?
 Throw raises an exception
 Catch defines a block that handles the exception
 Etc.
Niku AcademyCall Niku Software 9768264140 22
One Thing Is For Sure…
 Exceptions are NOT for dealing with errors
 They are a mechanism for changing the flow of
control from sequential to a branch if certain
conditions exist
 They always indicate expected circumstances.
Otherwise they could not possibly be
generated
Niku Academy
Niku Academy
9768 26 4140
Call Niku Software 9768264140 23

More Related Content

Similar to New Features in Dotnet Niku Software

Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitDimitry Snezhkov
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxgopikahari7
 
Legacy of Void*
Legacy of Void*Legacy of Void*
Legacy of Void*Adam Crain
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...Make Mannan
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...PROIDEA
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...Alessandro Confetti
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++Joan Puig Sanz
 

Similar to New Features in Dotnet Niku Software (20)

Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
 
VR Workshop #2
VR Workshop #2VR Workshop #2
VR Workshop #2
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 
Introduction to programming using c
Introduction to programming using cIntroduction to programming using c
Introduction to programming using c
 
Legacy of Void*
Legacy of Void*Legacy of Void*
Legacy of Void*
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
Kubernetes Intro
Kubernetes IntroKubernetes Intro
Kubernetes Intro
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Objective-C
Objective-CObjective-C
Objective-C
 
T2
T2T2
T2
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++
 
C# Unit 2 notes
C# Unit 2 notesC# Unit 2 notes
C# Unit 2 notes
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

New Features in Dotnet Niku Software

  • 1. Niku Academy What’s New In C# NIKU ACADEMY A Division Of Niku SoftwareCall Niku Software 9768264140 1
  • 2. Niku AcademyCall Niku Software 9768264140 2 C# Genealogy Fortran Algol 68 C C++ C# Cobol Eiffel JavaAda 95PL/I Pascal Elementary Procedural Advanced Procedural Special Procedural Object Oriented Advanced Object Oriented Ada 83
  • 3. Niku AcademyCall Niku Software 9768264140 3 C# And .Net  Languages like C# are not isolated entities  They interoperate in two ways:  By being part of a system written in more than one language  By accessing services and operating on a distributed environment  Requires support from run time:  .Net and the Common Language Runtime  .Net is many things, in particular binary object access  C# interoperates with .Net
  • 4. Niku AcademyCall Niku Software 9768264140 4 The Simple Stuff  Most of C# is pretty similar to languages you are used to:  Declarations  Expressions  Assignment and control statements  Other elements are quite similar:  Classes  Functions  Polymorphism
  • 5. Niku AcademyCall Niku Software 9768264140 5 Major Topics To Discuss  Identifier scope system—namespaces  Type system  Memory system and pointers  Execution time environment  Threads  Exceptions  Interfaces
  • 6. Niku AcademyCall Niku Software 9768264140 6 Namespaces Namespace CS415 Class A Class B Class C  Permits isolation of names  Can be nested  Access via fully qualified names Namespace CS340 Class A Class B Class C CS415.A… CS340.A…
  • 7. Niku AcademyCall Niku Software 9768264140 7 Type System  Type should be consistent:  Predefined and user-defined  All C# types derive from System.Object  Single rooted hierarchy  Provides four standard methods:  bool Equals  int GetHashCode  Type GetType  String ToString These don’t necessarily mean what you think Same object (ref) or same value (val) Retrieve object type (reflection) Retrieve object type (default)
  • 8. Niku AcademyCall Niku Software 9768264140 8 Types Of Types  Value types and reference types  Value types:  Program variables have a value  Space allocated on stack  Reference types:  Program variable is just a reference  Allocated space on stack  Reference is a “type-safe” pointer  Data space allocated on heap
  • 9. Niku AcademyCall Niku Software 9768264140 9 Value vs. Reference  Note the “special” status of primitive types System.Int32 myInt = 42; System.String myStr = “Hello World”; Circle c; c = new Circle(...); 42 address “Hello World” Stack Heap myStr myInt address Circle objectc Be careful with deallocation of the space
  • 10. Niku AcademyCall Niku Software 9768264140 10 Boxing And Unboxing  Conversion between value variable and reference variable System.Int32 myInt = 42; object o = myInt; int ymInt = (int)o; 42 o 42 Stack Heap Boxed myInt object o myInt
  • 11. Niku AcademyCall Niku Software 9768264140 11 The Role Of A Type System  What do we need from a type system?  Types across languages:  Consistency  Compatibility  Type safety:  Checking for meaningful statements  Add “speed” to “distance”?  C# vs Ada
  • 12. Niku AcademyCall Niku Software 9768264140 12 Memory Layout Stack Heap Garbage CollectorFunction Call & Return Pointers f() g() h() k() f calls g, g calls h, h calls k P*
  • 13. Niku AcademyCall Niku Software 9768264140 13 C# Memory Management  Static vs. dynamic  Dynamic storage—stack and heap  Stack (Dynamic):  Managed algorithmically by implementation of function calls  Heap (Dynamic)  Mostly managed by system  Provision for management by programmer
  • 14. Niku AcademyCall Niku Software 9768264140 14 C# Memory Management  Allocation using new  Deallocation by Garbage Collection  Garbage collection:  Tracks objects that are accessible  Frees storage associated with objects that are inaccessible  Garbage collector is a system provided service that runs periodically  Deals with fragmentation
  • 15. Niku AcademyCall Niku Software 9768264140 15 Garbage Collector Pros & Cons  Pros:  Programmer does not have to implement  Memory management done right  Cons:  No guarantee when it runs, hence no control  Takes processor resources  Does not delete storage if it is still reachable even if you don’t want it…  Memory leaks can (and do) still occur
  • 16. Niku AcademyCall Niku Software 9768264140 16 Some Specifics of C#  Object destruction via Object.Finalize:  Inherited from Object type  Override to destroy object as desired  Garbage collector available via GC class:  Runs via separate thread  Various methods available for access  E.g., GC.collect()  Pointers—yes, they are provided:  Syntax like C++, code marked unsafe  Objects managed by GC or user—pinned Object cannot be moved
  • 17. Niku AcademyCall Niku Software 9768264140 17 Traditional Compilation Source Program Compiler Object Program Linkage Editor Object Program Loader Binary Program Machine Instructions For Specific Target Object Code Libraries Relocatable Relocatable Not Relocatable Dynamic Linking Static Linking
  • 18. Niku AcademyCall Niku Software 9768264140 18 More Flexible Compilation Source Program Compiler Microsoft Intermediate Language (MSIL) Program TARGET Run-time Support System Machine Instructions For Multiple Targets TARGET Run-time Support System Interpreter Just-in-Time (JiT) Comp
  • 19. Niku AcademyCall Niku Software 9768264140 19 Concurrency  Threads vs. processes/tasks  C# supports threads Thread Thread Thread Thread Data Communication Who is running and when? What exactly are the problems here?
  • 20. Niku AcademyCall Niku Software 9768264140 20 C# Threads  System.Threading namespace  Facilities include:  Thread creation, destruction  Child thread management, e.g. join()  Thread scheduling, priority, timing  Synchronization:  Monitors  Semphores (mutex class)  Lock—serialization of statement block
  • 21. Niku AcademyCall Niku Software 9768264140 21 Exceptions  Why do we need exceptions?  How should they be made available in programming languages?  What benefits do they provide?  What problems could they cause for us?  Throw raises an exception  Catch defines a block that handles the exception  Etc.
  • 22. Niku AcademyCall Niku Software 9768264140 22 One Thing Is For Sure…  Exceptions are NOT for dealing with errors  They are a mechanism for changing the flow of control from sequential to a branch if certain conditions exist  They always indicate expected circumstances. Otherwise they could not possibly be generated
  • 23. Niku Academy Niku Academy 9768 26 4140 Call Niku Software 9768264140 23