SlideShare a Scribd company logo
1 of 15
Intro ++ to C#
1.Primitive Types
2.Reference Types
3.Special Types
4.Casting
5.Collections
6.Event
7.Lambdas
8.Linq
Primitive Types
Primitive types represent simple values
Description Signed Unsigned
Boolean (true or false) - bool
Characters (such as 'a', '1', '?') - char
Bytes (8-bit) sbyte byte
Short integer (16-bit) short ushort
Integer (32-bit) int uint
Long integer (64-bit) long ulong
Floating-point (32-bit) float -
Double precision floating-point (64-bit) double -
Reference Types
Reference types are classes
A program creates instances (or objects) of
classes
It keeps references to these instances in
variables
When an instance has no more reference to it, it
will eventually be destroyed by the garbage
collection.
null is a special value that represents a reference
to nothing
Classes
Classes have 4 kinds of members:
Fields (the data): variables kept in the instance
Methods (the code): actions that the code can
perform
Properties (some more code): they're used like fields
with some extra logic around the manipulation
Events: a way for the code to register/unregister
callbacks to respond to events
Inheritance
Classes can derive from others
Every class implicitly derives from System.Object
Virtual, override modifiers
ToString(), GetHashCode(), Equals()
Access Modifiers
private: can only be accessed by this class
protected: can only be accessed by this class
and its derived classes
internal: can be accessed from anywhere in the
same project (or assembly)
public: can be accessed from anywhere
static: associate the member with the type
instead of the instance
Static members don't have access to non-static
members
Non-static members have access to static members
Some Special Types
string: this is a class containing a collection of
characters.
enum: an enumeration is a list of words
associated with int values. It is a very convenient
way to give meaningful names to constant values,
make the code easier to read.
struct: structures are like class but are handled
by value, not by reference. They're useful for small
amount of data, such as vectors or matrices.
Casting
C-style casting
Operator is
Operator as
Control Flow Statements
Branching
If, else
Switch, case
Loops
For
Foreach
While
Do, while
Break, continue and goto
Method Arguments
Regular args.
The caller
passes a copy
of the value to
the callee
If the callee
modifies the
argument, it
only modifies
the copy, not
the original
ref args
The caller
passes a
reference to the
value
If the callee
modifies the
reference, it
also affects the
original
out args
Same as a ref
argument
The caller
doesn't need to
initialize it
The callee has
to write it
It's like an
extra return
value
Collections
Arrays: static, items cannot be added or removed
Lists: dynamic, items can be added and removed
Dictionaries: key-value storage. Values are
accessed by key instead of indices
Sorted Collection: each collection has a sorted
version to allow faster searches (but slower
insertions and removals)
Events
Events are useful when many objects need to be
notified when something is happening.
The naive approach: the emitter explicitly calls all the
interested objects
The fancy approach: all the interested objects
register to the emitter, which will fire its event that will
be propagated to the registered ones.
Lambda Expressions
Very convenient way to add small anonymous
functions within other functions
Can make the code harder to read when
overused
Linq Expressions
Convenient operations on collection
Conversion
Filtering
Transforming
Counting
Merging
Intersecting
…
Have a small performance penalty
Can make the code hard to read
Some Tips for the Road
Keep it simple! Don't over engineer, keep the
code as complex as the task it performs, not
more.
Naming things is difficult, but important. Code is
written once, but read many times. Spend a little
more time finding good names, it will pay back.
Organize your code in a way that will make it
easy to retrieve your stuff.

More Related Content

What's hot

What's hot (19)

Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - List
 
Data structures2
Data structures2Data structures2
Data structures2
 
LISP:Predicates in lisp
LISP:Predicates in lispLISP:Predicates in lisp
LISP:Predicates in lisp
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
LISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP: Type specifiers in lisp
LISP: Type specifiers in lisp
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
 
Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7
 
Safety Beyond Types
Safety Beyond TypesSafety Beyond Types
Safety Beyond Types
 
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4
 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
 
Binary search
Binary searchBinary search
Binary search
 
Object Class
Object ClassObject Class
Object Class
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
Xtext: type checking and scoping
Xtext: type checking and scopingXtext: type checking and scoping
Xtext: type checking and scoping
 
C# Collection classes
C# Collection classesC# Collection classes
C# Collection classes
 
Java util
Java utilJava util
Java util
 
Lists in Python
Lists in PythonLists in Python
Lists in Python
 
Knolx Session: Introducing Extractors in Scala
Knolx Session: Introducing Extractors in ScalaKnolx Session: Introducing Extractors in Scala
Knolx Session: Introducing Extractors in Scala
 
Report cs3 pillos
Report cs3 pillosReport cs3 pillos
Report cs3 pillos
 

Viewers also liked

c# events, delegates and lambdas
c# events, delegates and lambdasc# events, delegates and lambdas
c# events, delegates and lambdasFernando Galvan
 
[Development Simply Put] Events & Delegates In C# - Win Forms Controls
[Development Simply Put] Events & Delegates In C# - Win Forms Controls[Development Simply Put] Events & Delegates In C# - Win Forms Controls
[Development Simply Put] Events & Delegates In C# - Win Forms ControlsAhmed Tarek Hasan
 
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_1712 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17Niit Care
 
Java event processing model in c# and java
Java  event processing model in c# and javaJava  event processing model in c# and java
Java event processing model in c# and javaTech_MX
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteHock Leng PUAH
 

Viewers also liked (20)

PGI3 - Creating Art with Rekka Bell
PGI3 - Creating Art with Rekka BellPGI3 - Creating Art with Rekka Bell
PGI3 - Creating Art with Rekka Bell
 
Presentation
PresentationPresentation
Presentation
 
PGI3 - Intro to Programming
PGI3 - Intro to ProgrammingPGI3 - Intro to Programming
PGI3 - Intro to Programming
 
Info Session: Pixelles Game Incubator 3
Info Session: Pixelles Game Incubator 3Info Session: Pixelles Game Incubator 3
Info Session: Pixelles Game Incubator 3
 
Twine intro by Tanya Short
Twine intro by Tanya ShortTwine intro by Tanya Short
Twine intro by Tanya Short
 
Info Session - Pixelles Game Incubator 5
Info Session - Pixelles Game Incubator 5Info Session - Pixelles Game Incubator 5
Info Session - Pixelles Game Incubator 5
 
Pixelles Game Incubator 4 Info Session (2015-2016)
Pixelles Game Incubator 4 Info Session (2015-2016)Pixelles Game Incubator 4 Info Session (2015-2016)
Pixelles Game Incubator 4 Info Session (2015-2016)
 
Info Session: Pixelles Game Incubator 2
Info Session: Pixelles Game Incubator 2 Info Session: Pixelles Game Incubator 2
Info Session: Pixelles Game Incubator 2
 
Pixelles Info Session
Pixelles Info SessionPixelles Info Session
Pixelles Info Session
 
Making Video Games. Everyone! Get in Here!
Making Video Games. Everyone! Get in Here!Making Video Games. Everyone! Get in Here!
Making Video Games. Everyone! Get in Here!
 
PGI3 - Mechanics, Dynamics, and Aesthetics
PGI3 - Mechanics, Dynamics, and AestheticsPGI3 - Mechanics, Dynamics, and Aesthetics
PGI3 - Mechanics, Dynamics, and Aesthetics
 
UI/UX with Bio Jade
UI/UX with Bio JadeUI/UX with Bio Jade
UI/UX with Bio Jade
 
c# events, delegates and lambdas
c# events, delegates and lambdasc# events, delegates and lambdas
c# events, delegates and lambdas
 
[Development Simply Put] Events & Delegates In C# - Win Forms Controls
[Development Simply Put] Events & Delegates In C# - Win Forms Controls[Development Simply Put] Events & Delegates In C# - Win Forms Controls
[Development Simply Put] Events & Delegates In C# - Win Forms Controls
 
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_1712 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
 
Spf chapter10 events
Spf chapter10 eventsSpf chapter10 events
Spf chapter10 events
 
Java event processing model in c# and java
Java  event processing model in c# and javaJava  event processing model in c# and java
Java event processing model in c# and java
 
Ch01
Ch01Ch01
Ch01
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web site
 

Similar to Intro++ to C#

Similar to Intro++ to C# (20)

Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
 
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
 
C# - Igor Ralić
C# - Igor RalićC# - Igor Ralić
C# - Igor Ralić
 
(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii
 
Java basics
Java basicsJava basics
Java basics
 
Of Lambdas and LINQ
Of Lambdas and LINQOf Lambdas and LINQ
Of Lambdas and LINQ
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
Java Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsJava Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and Pitfalls
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
 
An Introduction to the C++ Standard Library
An Introduction to the C++ Standard LibraryAn Introduction to the C++ Standard Library
An Introduction to the C++ Standard Library
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
chapter 5.ppt
chapter 5.pptchapter 5.ppt
chapter 5.ppt
 
Intro To Scala
Intro To ScalaIntro To Scala
Intro To Scala
 
C#
C#C#
C#
 
Java 8 Streams
Java 8 StreamsJava 8 Streams
Java 8 Streams
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
 
Sysprog 9
Sysprog 9Sysprog 9
Sysprog 9
 

Recently uploaded

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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
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
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Intro++ to C#

  • 1. Intro ++ to C# 1.Primitive Types 2.Reference Types 3.Special Types 4.Casting 5.Collections 6.Event 7.Lambdas 8.Linq
  • 2. Primitive Types Primitive types represent simple values Description Signed Unsigned Boolean (true or false) - bool Characters (such as 'a', '1', '?') - char Bytes (8-bit) sbyte byte Short integer (16-bit) short ushort Integer (32-bit) int uint Long integer (64-bit) long ulong Floating-point (32-bit) float - Double precision floating-point (64-bit) double -
  • 3. Reference Types Reference types are classes A program creates instances (or objects) of classes It keeps references to these instances in variables When an instance has no more reference to it, it will eventually be destroyed by the garbage collection. null is a special value that represents a reference to nothing
  • 4. Classes Classes have 4 kinds of members: Fields (the data): variables kept in the instance Methods (the code): actions that the code can perform Properties (some more code): they're used like fields with some extra logic around the manipulation Events: a way for the code to register/unregister callbacks to respond to events
  • 5. Inheritance Classes can derive from others Every class implicitly derives from System.Object Virtual, override modifiers ToString(), GetHashCode(), Equals()
  • 6. Access Modifiers private: can only be accessed by this class protected: can only be accessed by this class and its derived classes internal: can be accessed from anywhere in the same project (or assembly) public: can be accessed from anywhere static: associate the member with the type instead of the instance Static members don't have access to non-static members Non-static members have access to static members
  • 7. Some Special Types string: this is a class containing a collection of characters. enum: an enumeration is a list of words associated with int values. It is a very convenient way to give meaningful names to constant values, make the code easier to read. struct: structures are like class but are handled by value, not by reference. They're useful for small amount of data, such as vectors or matrices.
  • 9. Control Flow Statements Branching If, else Switch, case Loops For Foreach While Do, while Break, continue and goto
  • 10. Method Arguments Regular args. The caller passes a copy of the value to the callee If the callee modifies the argument, it only modifies the copy, not the original ref args The caller passes a reference to the value If the callee modifies the reference, it also affects the original out args Same as a ref argument The caller doesn't need to initialize it The callee has to write it It's like an extra return value
  • 11. Collections Arrays: static, items cannot be added or removed Lists: dynamic, items can be added and removed Dictionaries: key-value storage. Values are accessed by key instead of indices Sorted Collection: each collection has a sorted version to allow faster searches (but slower insertions and removals)
  • 12. Events Events are useful when many objects need to be notified when something is happening. The naive approach: the emitter explicitly calls all the interested objects The fancy approach: all the interested objects register to the emitter, which will fire its event that will be propagated to the registered ones.
  • 13. Lambda Expressions Very convenient way to add small anonymous functions within other functions Can make the code harder to read when overused
  • 14. Linq Expressions Convenient operations on collection Conversion Filtering Transforming Counting Merging Intersecting … Have a small performance penalty Can make the code hard to read
  • 15. Some Tips for the Road Keep it simple! Don't over engineer, keep the code as complex as the task it performs, not more. Naming things is difficult, but important. Code is written once, but read many times. Spend a little more time finding good names, it will pay back. Organize your code in a way that will make it easy to retrieve your stuff.