Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
C# Series, Week 0
Jamshid Hashimi, CodeWeekend
Agenda
• What is C#?
• Why C#?
• History of C#
• What is Object?
• Object Oriented Programming
• Managed Languages
• C# Sy...
What is C#
• C# (pronounced "C-sharp") is an object-oriented programming
language from Microsoft that aims to combine the ...
Why C#?
• Modernized Language
• C# is a modernized version of C++
• It was C, then C++. Now it C#
• Type-safety
• You can ...
Why C#?
• XML Comments
• Comments can be source code independent
• Not Just Microsoft
• Mono
• The power to be unsafe
• Yo...
History of C#
• January 1999: Anders Hejlsberg formed a team to build a new
language, named Cool, which stood for “C-like ...
History of C#
• The name
• Inspired by musical notation where a sharp indicates that the written note
should made a semito...
What is Object?
• Object is the foundational piece of object oriented programming language.
• An object typically makes a ...
What is Object?
• Suppose you are a Personnel Manager for a company and need to hire
someone in an important position.
• Y...
What is Object?
Object Oriented Programming
• To be object oriented, a language is designed around the concept of
objects.
• Objects have ...
Object Oriented Programming
• Encapsulation
• The wall around code
• I don’t want you to get confused
• I just want you ge...
Object Oriented Programming
• Inheritance
• Fundamentally based on the idea of code reuse.
• You create behaviors, others ...
Object Oriented Programming
Object Oriented Programming
• Polymorphism
• from Greek πολύς, polys, "many, much" and μορφή, morphē, "form, shape"
• Obje...
Managed Languages
• Managed language depends on services provided by a runtime
environment
• C# is one of many programming...
Managed Languages
• Managed Code
• Managed code is a code that has its execution managed by .NET framework
Common Language...
C# Syntax
• C# syntax is based on C and C++ syntax
• Identifiers are names of classes, methods, variables and so on
• Cons...
C# Syntax
C# Syntax
C# Syntax
Thank You! 
Upcoming SlideShare
Loading in …5
×

Introduction to C# - Week 0

752 views

Published on

A general introduction to C#, the history, CIL, CLR, Managed languages and how to start.

Published in: Technology
  • Be the first to comment

Introduction to C# - Week 0

  1. 1. C# Series, Week 0 Jamshid Hashimi, CodeWeekend
  2. 2. Agenda • What is C#? • Why C#? • History of C# • What is Object? • Object Oriented Programming • Managed Languages • C# Syntax • Installing C# • Downloading and Installing Visual Studio
  3. 3. What is C# • C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. • Designed by: Microsoft • Developed by: Microsoft • First Appeared at: 2000, 15 years ago • Stable Release: 5.0 • Development Team Lead by: Anders Hejlsberg
  4. 4. Why C#? • Modernized Language • C# is a modernized version of C++ • It was C, then C++. Now it C# • Type-safety • You can not use uninitialized variables • You can not walk past the end of an array • Object Oriented • C# goes to another level, even simple data types can be treated as Objects. • Simplified Syntax • C++ is powerful but not easy. C# is type safe, for example C# does away with Pointers. C# do not allow direct memory manipulation, so pointers are not needed. • Header files have also been removed from C#. The namespace and reference operators, :: and -> respectively, have been replaced with a single operator, the period (.). • int and bool data types are completely different now! • C# removes memory management issues by using .NET garbage collection scheme.
  5. 5. Why C#? • XML Comments • Comments can be source code independent • Not Just Microsoft • Mono • The power to be unsafe • You can directly access to memory • If you want to drive without a seatbelt, you are free to do so. • Is a general purpose language • Dev Productivity
  6. 6. History of C# • January 1999: Anders Hejlsberg formed a team to build a new language, named Cool, which stood for “C-like Object Oriented Language”. • July 2000, PDC: Language name changed to C# • Anders Hejlsberg: • C# Principle designer and lead architect • Also designed Turbo Pascal and Delphi • Stated: Flaws in other languages (e.g. C++, Java, Delphi, and Smalltalk) drove the fundamentals of CLR, which, in return drove the design of C#. • “It is not a clone of Java, it is much closer to C++ in its design” • To many programmers, C# is Microsoft’s answer to Java.
  7. 7. History of C# • The name • Inspired by musical notation where a sharp indicates that the written note should made a semitone higher in pitch. • C++, means C incremented and C#, means C++ incremented. (# is made by four +)
  8. 8. What is Object? • Object is the foundational piece of object oriented programming language. • An object typically makes a concept. • An object is something e.g. customer • An object has data e.g. customer’s first name • An object performs action • Make a customer preferred • Color a car • Change customer’s name • Object is a thing • To define a thing we need to talk about its characteristics.
  9. 9. What is Object? • Suppose you are a Personnel Manager for a company and need to hire someone in an important position. • You select one resume, Jane • You are Jack • You call her • Arrange an interview, she will fly to your location • You two never met before, so started asking few questions from each other: height, hair type, cloth color and briefcase color • Without realizing it, you used objects in the course of your conversation • You created a Person class. A class is a template used to describe an object. • A class is an abstraction or simplification of some object your observe in the real world. • Objects has two basic components: • Properties that describe the object • Methods, or actions, that you want to associate with the object
  10. 10. What is Object?
  11. 11. Object Oriented Programming • To be object oriented, a language is designed around the concept of objects. • Objects have certain properties as exhibits certain behaviors. • It means language generally includes support for: • Encapsulation • Inheritance • Polymorphism
  12. 12. Object Oriented Programming • Encapsulation • The wall around code • I don’t want you to get confused • I just want you get in touch with me with the Windows and Doors. • A customer has a first name, but you don’t care how that’s stored. You just want to get in and extract the information needed. • We encapsulate to keep our code secure.
  13. 13. Object Oriented Programming • Inheritance • Fundamentally based on the idea of code reuse. • You create behaviors, others can use it through inheritance channel. • The quality you get from your parents 
  14. 14. Object Oriented Programming
  15. 15. Object Oriented Programming • Polymorphism • from Greek πολύς, polys, "many, much" and μορφή, morphē, "form, shape" • Objects can appear in different shapes, forms. • Instead of sticking with the concept of “many shapes”, perhaps the definition should be amended to mean “many messages.” • In essence Polymorphism means that you can send the same message to a group of different classes and that each class will know how to respond correctly to that message. • clsBuilding – base class, RemoveSnow() - virtual • clsApartment – RemoveSnow() - override • clsCommercial – RemoveSnow() – override • myApt.RemoveSnow() • myComm.RemoveSnow() • myHome.RemoveSnow() – We don’t have a RemoveSnow method for our clsHome object. Still it outputs.
  16. 16. Managed Languages • Managed language depends on services provided by a runtime environment • C# is one of many programming languages which it compiles into managed code. (others are: F#, C++, VB and more..) • Managed runtime in .NET is called Common Language Runtime (CLR) • Common Language Runtime (CLR) provides: • Automatic Memory Management • Exception Handling • Standard Types • Security
  17. 17. Managed Languages • Managed Code • Managed code is a code that has its execution managed by .NET framework Common Language Runtime (CLR) • When you compile C# code to .exe, it is compiled to Common Intermediate Language (CIL), bytecode. • Whenever you run a CIL executable, it is executed on Microsoft Common Language Runtime (CLR) virtual machine. • You must have the .NET runtime installed on any client machines where your program will be running. • C# do not compiles directly to machine code. It compiles to CIL (bytecode). CLR executes the bytecode to machine code.
  18. 18. C# Syntax • C# syntax is based on C and C++ syntax • Identifiers are names of classes, methods, variables and so on • Console, Writeline, AcceptDetails(), GetArea(), length, width, Display and so on. • Keywords are compiler reserved words • Public, class, string, get, set, void and so on. • Using keyword is used to include namespaces inside our program.
  19. 19. C# Syntax
  20. 20. C# Syntax
  21. 21. C# Syntax
  22. 22. Thank You! 

×