Documente Academic
Documente Profesional
Documente Cultură
NET-Simplified
Contents
ABOUT THE AUTHOR ................................................................................................................................................................. 4
1. CONDITIONAL: ....................................................................................................................................................................................... 24
CHAPTE 5 : UNDERSTANDING THE CONCEPT OF FOREACH LOOP AND SYSTEM.ARRAY METHODS IN C#. ..................... 64
www.manzoorthetrainer.com
C#.NET-Simplified
CHAPTER 14 : UNDERSTANDING THE CONCEPT OF INHERITANCE AND PROTECTED VARIABLES IN C#. ....................... 148
CHAPTER 16 : METHOD OVERRIDING, VARIOUS TYPES OF INHERITANCE AND CONSTRUCTOR CHAINING IN C#. ....... 168
CHAPTER 23 : CONCEPT OF DELEGATES, UNICAST DELEGATES AND MULTICAST DELEGATES IN C#. ........................... 239
www.manzoorthetrainer.com
C#.NET-Simplified
- ManzoorTheTrainer
www.manzoorthetrainer.com
C#.NET-Simplified
◉ Select Ok.
◉ Now it opens new window with Program.cs file name (i.e. Default page
whenever we start console application).
www.manzoorthetrainer.com
C#.NET-Simplified
◉ Our intention is to store 67 in n1, 56 in n2 and add n1 and n2 values and store
in n3.
◉ Int n1,n2,n3;
◉ n1=67;
◉ n2=56;
◉ n3=n1+n2;
www.manzoorthetrainer.com
C#.NET-Simplified
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MathOperationsEg
class Program
n1=67;
n2=56;
n3 = n1 + n2;
Console.WriteLine(n3);
Console.ReadLine();
www.manzoorthetrainer.com
C#.NET-Simplified
◉ Press F5.
◉ To display the values of n1, n2 and n3 simply we need to replace the n1, n2
and n3 with {0}, {1} and {2} as indexes in quotation.
◉ Now put comma after quotation and give the variable name at 0th position
(i.e. n1), n2 at 1st position and n3 at 3rd position.
www.manzoorthetrainer.com
C#.NET-Simplified
n1=67;
n2=56;
n3 = n1 + n2;
Console.ReadLine();
◉ Press F5.
◉ There is another way to display the same result using ‘+’ operator.
◉ Both of the methods display same result but using two different techniques.
◉ One is passing parameters kind of things like giving indexes for n number of
variables, and another is using ‘+’ operator for string concatenation.
www.manzoorthetrainer.com
C#.NET-Simplified
n1=6.7;
n2=56.7;
n3 = n1 + n2;
Console.ReadLine();
◉ Press F5.
◉ If we want to add different values we need not to go and edit the program
again and again.
◉ We can give the option to end user to enter the values from keyboard at
runtime.
10
www.manzoorthetrainer.com
C#.NET-Simplified
◉ n1= int.Parse(Console.ReadLine());
◉ n2= int.Parse(Console.ReadLine());
◉ n1= int.Parse(Console.ReadLine());
◉ n2= int.Parse(Console.ReadLine());
11
www.manzoorthetrainer.com
C#.NET-Simplified
◉ Press F5.
◉ If we have double values we need to change int type to double and instead
of int.Parse we need to use double.Parse.
◉ Double n1,n2,n3;
◉ n1= double.Parse(Console.ReadLine());
◉ n2= double.Parse(Console.ReadLine());
12
www.manzoorthetrainer.com
C#.NET-Simplified
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MathOperationsEg
class Program
n1 =int.Parse(Console.ReadLine());
n2 =int.Parse( Console.ReadLine());
n3 = n1 + n2;
Console.ReadLine();
◉ Press F5.
13
www.manzoorthetrainer.com
C#.NET-Simplified
◉ In this chapter we have seen addition of two integers and double numbers.
Thank you..!
14
www.manzoorthetrainer.com
C#.NET-Simplified
◉ Int a=5;
◉ Int b=2;
15
www.manzoorthetrainer.com
C#.NET-Simplified
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TypeCastEg
class Program
int a = 5;
int b = 2;
Console.WriteLine(a/b);
Console.ReadLine();
16
www.manzoorthetrainer.com
C#.NET-Simplified
◉ 5+2=7.
◉ If we say 5.0+2=7.0.
◉ See that there is not much difference in mathematical concept 7 and 7.0 both
are same.
◉ Whereas in our computer world 7 and 7.0 has lot of difference in their data
structure.
◉ One thing we need to observe here is ‘5’ is our first operand ‘2’ is our second
operand and ‘+’ called as operator.
17
www.manzoorthetrainer.com
Thank You for previewing this eBook
You can read the full version of this eBook in different formats:
To download this full book, simply select the format you desire below