C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to...

27
C# EMILEE KING

Transcript of C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to...

Page 1: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

C#EMILEE KING

Page 2: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

HISTORY OF C#

• In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system platforms.

• This led to the creation of the .NET Framework.

• In the Pre-release stage the .NET Framework used multiple languages

Page 3: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

HISTORY OF C#

• C++, Visual, and ASP all of which were used for different parts of the framework and were not interchangeable.

• Anders Hejlsberg and his team wanted to be able to offer a more unified solution for this framework.

• Modern concepts, such as object orientation, type safety, and garbage collection and structured exception handling directly into the platform.

Page 4: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

HISTORY OF C#

• COOL: C-Like Object Oriented Language

• C++ was seen as an increment of C

• C++++ so C# can be seen as an increment of C++

• The name for C# was changed and the language was publicly announced alongside the .NET project at the July 2000 Professional Developers Conference.

Page 5: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

NAMES

• Case-Sensitive: : sumOfAverages, SumOfAverages, SUMOFAVERAGES

• PascalCasing for class names and method names

• camelCasing for method arguments and local variables

• Use noun or noun phrases to name a class

• Avoid using SCREAMINGCAPS for constants or readonly variables

Page 6: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

KEYWORDS

• C# has two different types of keywords, contextual keywords and reserved keywords.

• Contextual keywords are only treated as keywords in certain situations.

• Reserved keywords are treated like keywords in all situations.

• Both are always lowercase

Page 7: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

BINDINGS

• Static and Dynamic

• C# defaults to static

• Allows dynamic binding for certain operations:

• Member access

• Element access

• Method invocation

• Assignment operators

Page 8: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

DATA TYPES: VALUE TYPES

• Instances of value types are allocated on the stack.

• Primitive Data Types: Int, Float, Char.

• User Defined Structures (Structs)

• Cannot derive from each other

• Cannot have explicit constructors

• Bound to their variables, so inefficient for sharing data between classes

Page 9: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

DATA TYPES: REFERENCE TYPES

• Instances of a reference type are allocated in the heap.

• Strings, Arrays, Class types, Delegates

• Contains the address of a location in memory where the data referred to by that variable is stored

• When the variable is not referencing any object the variable will be null.

• Will not be destroyed until C#’s garbage collection system determines that it is no longer needed.

Page 10: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

GENERICS

• C# is a strongly typed language

• Generics were introduced in Version 2.0 of .NET Framework

• Combine reusability, type safety and efficiency in a way that their non-generic counterparts cannot

• Avoids computational cost of boxing and unboxing.

• Allows the compiler to do type-checking

Page 11: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

ARRAYS

• One dimension

• Multidimensional

• Array of Arrays (Jagged Arrays)

Page 12: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

EXPRESSIONS AND ASSIGNMENT STATEMENTS

• Left to Right

• Primary: x.y, f(x), a[x], x++, x--

• Unary: +, -, !, ~, ++x, --x, (T)x

• PEMDAS

• Shift: <<, >>

• Relational and type testing: <, >, <=, >=, is, as

• Equality: ==, !=

• Logical Expressions: &, ^, |

• Conditional Expressions &&, ||, ?:

Page 13: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

CONDITIONAL STATEMENTS

• If-else

• Else-if

• Switch Statements

Page 14: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

ITERATIVE STATEMENTS

• While

• Do While

• For Loop

• For Each Loop

Page 15: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

METHODS

• Methods define how a class should behave

• Structs can have methods

• Can not be nested

• Can be passed as parameters called Delegates

• Can have any type including user defined and void

Page 16: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

CLASSES

• Reference Types

• Can be nested

• Support inheritance

• Used for data that might be modified after the class is created

• Can implement interfaces

Page 17: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

STRUCTS

• Value type

• Do not support inheritance

• Used for data that will not be modified after the struct is created

• Can implement interfaces

• Unlike C++ structs, C# structs are light weight classes

Page 18: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

OPERATOR OVERLOADING

• Unary, binary, and comparison operators can be overloaded

• Cast operators and array indexing cannot be overloaded

• Conversion operators can be defined for cast operators

• New indexers can be defined for array indexing

Page 19: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

ABSTRACT DATA TYPES AND ENCAPSULATION CONSTRUCTS

• Similar to C++ and Java

• C# allows destructors, although rarely used due to garbage collection

• Two new access modifiers: Internal and Protected Internal

• Properties can implement getters and setters without explicit method calls

Page 20: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

SUPPORT FOR OBJECT ORIENTED PROGRAMMING

• Encapsulation

• Inheritance

• Polymorphism

• Dynamic Binding

• Nested classes

• Classes and Structs can implement interfaces

Page 21: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

CONCURRENCY

• Based largely on Java

• Supports actor and server threads

• Built in classes for thread synchronization

• Interlocked class

• Monitor class

Page 22: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

EXCEPTION HANDLING

• Large amount of predefined exception classes

• Allows user defined exceptions

• Try block is where potential problem code is located

• Catch catches an exception (also known as exception filter)

• Finally block executes code regardless of how try block is exited

Page 23: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

EVENT HANDLING

• Static and Dynamic

• Static: only in effect in the class of the events that they handle

• Dynamic: activated and deactivated throughout the entire program in response to their conditional programming logic.

• Both use two parameters that are always of type object and EventArgs

Page 24: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

READIBILITY

• Very organized

• Regions

• Intuitive

• User defined structs and enumerations allows programmers to clearly label what their program is doing

Page 25: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

WRITABILITY

• Many different ways to write code and get the same effect

• Intuitive

• Allows for user defined structs and enumerations

Page 26: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

RELIABILITY

• Strongly typed language

• Strict with type checking

• Large amount of built in exception handling

• Allows for user defined exception handling

• Unsafe code has to be explicitly marked and enabled in the compiler

• Large amount of documentation online

Page 27: C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.

COST

• Visual Studio

• Commercial Version

• Training

• Large amount of documentation online by Microsoft

• Updates