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.
Getting Dirty – Part 1
Jamshid Hashimi, CodeWeekend
Agenda
• Expressions, Types, and Variables
• Control Statements - Selection
• Control Statements - Loops
• Methods
• Names...
Expressions, Types, and Variables
• Variables: storage locations for data
• int num = 428;
• C# is a strongly typed langua...
Expressions, Types, and Variables
• The Boolean Type
• Declared by keyword: bool
• Has two values: true or false
Expressions, Types, and Variables
• In C++, a value of type bool can be converted to a value of type int; in
other words
•...
Expressions, Types, and Variables
• Integral Types
• Number, either signed and unsigned and char type
Expressions, Types, and Variables
• Floating Point and Decimal Types
• To represent real numbers
Expressions, Types, and Variables
• The String Type
• A string is a sequence of text characters.
• “This is a string examp...
Expressions, Types, and Variables
• Operands and Operators
• Operand is a piece of information or data
• Operator specifie...
Expressions, Types, and Variables
• Statements
• In C#, a program statement is one or more expressions terminated by a
sem...
Expressions, Types, and Variables
Expressions, Types, and Variables
• solution = 2 + 3 * 4 + 5;
• Overriding the default Precedence order
• Solution = (2 + ...
Control Statements - Selection
• If statements
• An if statement allows you to take different paths of logic, depending on...
Control Statements - Selection
• Switch Statements
• A type of selection control mechanism used to allow the value of a va...
Control Statements - Loops
• Learn the while loop
• A while loop will check a condition and then continues to execute a bl...
Control Statements - Loops
• Learn the for loop
• By using a for loop, you can run a statement or a block of statements
re...
Methods
• Methods are to split our logic into units
• Name should be meaningful
• Should be associated with the task
• Par...
Methods
• Instance Methods
• Static Methods
• Pass by value
• Pass by reference
• this keyword
Namespaces
• Namespaces are C# program elements designed to help you organize
your programs.
• Also to avoid name conflicts
Introduction to Classes
• Classes are templates to objects
• Constructors
• Instance and Static methods, again!
• Destruct...
Inheritance
• Inheritance is one of the primary concepts of object-oriented
programming. It allows you to reuse existing c...
Polymorphism
• It allows you to invoke derived class methods through a base class
reference during run-time.
• Sending the...
Thank You! 
Upcoming SlideShare
Loading in …5
×

Week 1: Getting Dirty - Part 1

614 views

Published on

Csharp expressions, types, variables, control statements of both selection and loops, methods, namespaces, classes, inheritance and polymorphism topics are included in this presentation.

Published in: Technology
  • Be the first to comment

Week 1: Getting Dirty - Part 1

  1. 1. Getting Dirty – Part 1 Jamshid Hashimi, CodeWeekend
  2. 2. Agenda • Expressions, Types, and Variables • Control Statements - Selection • Control Statements - Loops • Methods • Namespaces • Introduction to Classes • Class Inheritance • Polymorphism
  3. 3. Expressions, Types, and Variables • Variables: storage locations for data • int num = 428; • C# is a strongly typed language. • All operations are based on variable Types • C# simple types consist of: • Boolean Type • 3 numeric type: Integrals, Floating Point, Decimal • String
  4. 4. Expressions, Types, and Variables • The Boolean Type • Declared by keyword: bool • Has two values: true or false
  5. 5. Expressions, Types, and Variables • In C++, a value of type bool can be converted to a value of type int; in other words • false is equivalent to zero and true is equivalent to nonzero values. • In C#, there is no conversion between the bool type and other types.
  6. 6. Expressions, Types, and Variables • Integral Types • Number, either signed and unsigned and char type
  7. 7. Expressions, Types, and Variables • Floating Point and Decimal Types • To represent real numbers
  8. 8. Expressions, Types, and Variables • The String Type • A string is a sequence of text characters. • “This is a string example” • Some characters are not printable
  9. 9. Expressions, Types, and Variables • Operands and Operators • Operand is a piece of information or data • Operator specifies what action should be done with the operand(s). • operandOne operator operandTwos • Expressions • An expression is simply one or more operands and their associated operator treated as a single entity. • answer = operand1 / operand2
  10. 10. Expressions, Types, and Variables • Statements • In C#, a program statement is one or more expressions terminated by a semicolon. • answer = operand 1 / operand2;
  11. 11. Expressions, Types, and Variables
  12. 12. Expressions, Types, and Variables • solution = 2 + 3 * 4 + 5; • Overriding the default Precedence order • Solution = (2 + 3) * (4 + 5);
  13. 13. Control Statements - Selection • If statements • An if statement allows you to take different paths of logic, depending on a given condition. • There are two forms of OR: • Regular OR (|) operator will evaluate both sub-expressions every time. • Conditional OR (||) will evaluate the second sub-expression only if the first sub- expression evaluates to false. • There are two forms of AND: • Regular AND operator will evaluate both expressions every time. • Conditional AND operator will evaluate the second sub-expression only when the first sub-expression evaluates to true.
  14. 14. Control Statements - Selection • Switch Statements • A type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution via a multiway branch. • Break! • Go to!
  15. 15. Control Statements - Loops • Learn the while loop • A while loop will check a condition and then continues to execute a block of code as long as the condition evaluates to a boolean value of true. • Learn the do loop • A do loop is similar to the while loop, except that it checks its condition at the end of the loop.
  16. 16. Control Statements - Loops • Learn the for loop • By using a for loop, you can run a statement or a block of statements repeatedly until a specified expression evaluates to false. • Learn the foreach loop • The foreach statement repeats a group of embedded statements for each element in an array or an object collection.
  17. 17. Methods • Methods are to split our logic into units • Name should be meaningful • Should be associated with the task • Parameters are to transfer information to and from method attributes modifiers return-type method-name(parameters) { statements }
  18. 18. Methods • Instance Methods • Static Methods • Pass by value • Pass by reference • this keyword
  19. 19. Namespaces • Namespaces are C# program elements designed to help you organize your programs. • Also to avoid name conflicts
  20. 20. Introduction to Classes • Classes are templates to objects • Constructors • Instance and Static methods, again! • Destructors • To release the allocated resources
  21. 21. Inheritance • Inheritance is one of the primary concepts of object-oriented programming. It allows you to reuse existing code.
  22. 22. Polymorphism • It allows you to invoke derived class methods through a base class reference during run-time. • Sending the same message, getting the correct response
  23. 23. Thank You! 

×