Lecture 3
Lecture 3
SOFTWARE
DEVELOPMENT
~THARUKA PERERA
Lecture 03
Foundation Certification in IT – UOB batch 1
2
Operators in C#
OVERVIEW
Strings Handling in C#
3
OPERATORS IN C#
COMPARISON: Would not evaluate the second condition if the result of the
first condition would already decide the final outcome.
LOGICAL AND Ex 1: (false) && (x++ > 10) --- no need to evaluate
the 2nd condition because first condition gets False. Due to
CONDITIONAL use &&, it not wants to check second condition.
OPERATORS Ex 2:
if (count != 0 && total /count)
{
…
}
ASSIGNMENT OPERATIONS
You can consider assignment as another The right- and left-hand sides of an
operator, with a lower precedence than assignment statement can contain the
the arithmetic operators same variable
ASSIGNMENT OPERATORS
class Increment
{
static void Main(string[] args)
{
int c;
c = 5;
Console.WriteLine( c ); // print 5
Console.WriteLine( c++ ); // print 5 then postincrement
Console.WriteLine( c ); // print 6
c = 5;
Console.WriteLine( c ); // print 5
Console.WriteLine( ++c ); // preincrement then print 6
Console.WriteLine( c ); // print 6
}
STRING HANDLING IN C#
Example 1 –
string part1 = "SLIIT";
string part2 = " Academy"; SLIIT Academy
string part3 = part1 + part2;
Console.WriteLine(part3);
Example 2 –
string part1 = "SLIIT";
string part2 = " Academy"; SLIIT Academy
string part3 = string.Concat(part1,part2);
Console.WriteLine(part3);
Example 3 –
string x = “1"; 12
string y = " 2";
string part3 = part1 + part2;
Console.WriteLine(part3);
STRING HANDLING IN C#
Example 2 –
Console.WriteLine(“using \’ in Output”); Using ‘ in output
Example 3 –
Console.WriteLine(“using \\ in Output”); Using \ in output
Example 4 –
Console.WriteLine(“using \n new line character”); Using
new line character
Example 5 –
Console.WriteLine(“using \t tab line character”); Using tab line character
Operators in C#
LET'S
SUMMARIZE
String Handling in C#
14
SEE YOU NEXT
WEEK
15