Lecture 4 - Working With Variables, Data Types, Operators, and Expressions
Lecture 4 - Working With Variables, Data Types, Operators, and Expressions
https://sites.google.com/a/quest.edu.pk/dr-irfana-memon/lecture-slides
Course Content
Review of C# Syntax: Overview of Writing Applications using C#, Data types,
Operators, and Expressions
C# Programming Language Constructs, Creating Methods
Invoking Methods, Handling Exceptions, Creating overloaded Methods
Developing the Code for a Graphical Application: Implementing Structs and Enums
Implementing Type-safe Collections: Creating Classes, Organizing Data into Collections,
6
C# Keywords
• Keywords are predefined sets of reserved words that have
special meaning in a program.
• The meaning of keywords can not be changed, neither can
they be directly used as identifiers in a program.
• Although keywords are reserved words, they can be used as
identifiers if @ is added as prefix.
7
List of C# Keywords
• C# has a total of 79 keywords. All these keywords are in
lowercase. Here is a complete list of all C# keywords.
abstract as base bool
break byte case catch
char checked class const
continue decimal default delegate
do double else enum
12
Exercise
2. Write C# code to display the asterisk pattern as shown
below: using System;
***** namespace Csharp_exercises
***** {
***** class Program
***** {
string name;
17
Operators
We will learn everything about different types of operators
in C# programming language and how to use them.
Table of Contents
Basic Assignment Operator
Arithmetic Operators
19
Arithmetic Operators
• Arithmetic operators are used to perform arithmetic
operations such as addition, subtraction, multiplication,
division, etc.
24
Bitwise and bit shift Operators
• Bitwise and bit shift operators are used to perform bit
manipulation operations.
~ Bitwise Complement
25
Compound Assignment Operators
Operator Operator Name Example Equivalent To
26
>>= Right Shift Assignment x >>= 5 x = x >> 5
using System;
namespace Operator
{
class ArithmeticOperator
38
Wish You Good Luck