software development program
TRANSCRIPT
-
8/3/2019 Software Development Program
1/25
Software Development
Training Program
Zeeshan Hanif
-
8/3/2019 Software Development Program
2/25
Cloud Computing - 101Lecture 2
Zeeshan [email protected]
-
8/3/2019 Software Development Program
3/25
First C# Programusing System;
public class First
{
public static void Main(string[] args)
{
Console.WriteLine(I belong toOperation Badar);
}
}
-
8/3/2019 Software Development Program
4/25
Parts of a C# Program Class Name
public class First
Main methodpublic static void Main(string[]args)
StatementsConsole.WriteLine(I belong to
Operation Badar);
-
8/3/2019 Software Development Program
5/25
Bits and Bytes Bit is the smallest unit of storage
Bit is a digit that can have only twovalues: 0 or 1
A byte is made up of 8 bits
1 0 0 1 1 1 0 1
1 Byte
8 Bits
-
8/3/2019 Software Development Program
6/25
Memory allocation10011001
11111001
01110101
10010101
11000001
10111001
01001110
11000101
Main Memory
-
8/3/2019 Software Development Program
7/25
Types of Data: Datatypes Data types are very important in every
language for storing and manipulating
data
Different kinds of data exist
All have different features hence
difference requirements
Nature of data determines its type
-
8/3/2019 Software Development Program
8/25
Datatypes and size in memory Integer Types
C#Keyword
Sizebits/bytes
Signed/Unsigned
Type inSystem
Range
sbyte 8 bits / 1 byte signed SByte -128 to 127byte 8 bits / 1 byte unsigned Byte 0 to 255
short 16 bits / 2 bytes signed Int16 -32765 to 32768
ushort 16 bits / 2 bytes unsigned UInt16 0 to 65535
int 32 bits / 4 bytes signed Int32 -2147483648 to 2147483647
uint 32 bits / 4 bytes unsigned UInt32 0 to 4294967195
long 64 bits / 8 bytes signed Int64 -9223373036854775808 to -9223373036854775807
ulong 64 bits / 8 bytes unsigned UInt64 0 to 18446744073709551615
-
8/3/2019 Software Development Program
9/25
Datatypes and size in memory Floating-Point and Decimal Types
C#
Keyword
Size
bits/bytes
Significant
Figures
Type in
System
Range
float 32 bits /
4 bytes
7 Single -3.40282347E38 to 3.40282347E381.5 * 10-45 to 3.4 * 1038
double 64 bits /
8 bytes
15 Double -1.7976931348623157E308 to1.7976931348623157E308
5.0 * 10-324 to 1.7 * 10308
decimal 96 bits /
12 bytes
28 Decimal -79228162514264337593543950335to79228162514264337593543950335
1.0 * 10-28 to 7.9 * 1028
-
8/3/2019 Software Development Program
10/25
Datatypes and size in memory Character Types
C#Keyword
Sizebits/bytes
Type inSystem
Value
bool 8 bits / 1 byte Boolean true and false
Boolean Types
C#Keyword
Sizebits/bytes
Type inSystem
Value
char 16 bits / 2 bytes Char All Unicode Character
-
8/3/2019 Software Development Program
11/25
Literals A value of any kind is called a literal
Integer literals
int count = 2250; / long = 7854214; Floating point literals
double d=2.5 E-5.0; / decimal f = 34.34m; Character literals
char c=B; Boolean literals
bool b=false; // also true
-
8/3/2019 Software Development Program
12/25
Literals NOTE :
All the integer types are considered int or long typeby default.
All the floating point types are considered double bydefault.
So if you want to store 4.4 in float datatype you can
not write this: - float f = 4.4; / decimal d = 4.4;
Instead you write float f = 4.4f; decimal d = 4.4m;
This way you explicitly tell the compiler to treat 4.4as float.
-
8/3/2019 Software Development Program
13/25
Literals If you want to add two byte or short
like:
byte a = 5;byte b = 5;
byte c = a+b;
Instead you write
byte a = 5;
byte b = 5;
int c = a+b;
-
8/3/2019 Software Development Program
14/25
Binary Representation Decimal Numbers
Binary numbers
Conversion of decimal numbers intobinary
Conversion of binary numbers intodecimal numbers
-
8/3/2019 Software Development Program
15/25
What is a Variable? `vary`-ablemeans change-able
The variable is the basic unit of storage. A
variable is defined by the combination of atype, variable name and an optionalinitializer. In c# all variables must bedeclared before they can be used.
int a = 4;
TypeName
Initial value
-
8/3/2019 Software Development Program
16/25
Example Some variable declarations examples: -
1. int a = 3;
2. int x,y,z;x = 4;y = 6;z = 3;
3. char c = a; 4. bool b = true;
5. double d = 44.4, v = 43.3;
-
8/3/2019 Software Development Program
17/25
What is a Identifier? Identifiers are used to name variables,
classes, interfaces, methods, and other
elements.An identifier is a sequence of characters
that starts with an underscore (_), or a
letter. Subsequent characters maycontain these characters plus the digits0 through 9.
-
8/3/2019 Software Development Program
18/25
Rules for Identifiers A-Z, a-z, 0-9,_,@ Must not start with digit
So followings are valid identifiers: - _minute total Sum4
Hello67_hello abc_34 _34343
-
8/3/2019 Software Development Program
19/25
Invalid Identifiers Followings are invalid identifiers: -
&total
Minute#
4hour
12hello abc@abc
$asdfa
-
8/3/2019 Software Development Program
20/25
Identifiers Both uppercase and lowercase letters
can be used in an identifier. Because
C# is case sensitive, therefore these aretreated as different identifiers: -
Total
total TOTAL
toTal
-
8/3/2019 Software Development Program
21/25
What is a Keyword?abstract default foreach null sealed uintas delegate goto object short ulong
base do if operator sizeof unchecked
bool double implicit out stackalloc unsafebreak else in override static ushort
byte enum int params string using
case event interface private struct virtual
catch explicit internal protected switch void
checked extern is public this while
class false lock readonly throw
const finally long ref true
continue fixed namespace return try
decimal float new sbyte typeof
-
8/3/2019 Software Development Program
22/25
Casting / Conversion Implicit casting
When one type of data is assigned to theother type of variable, an automatic typeconversion occurs if left hand type is largerthan the right hand type. This conversion is
sometimes called widening conversion sinceyou are converting small value to largevalue.
-
8/3/2019 Software Development Program
23/25
Casting / Conversionbyte a = 5;
int b = a;
long c = b;double d = c;
All the above are implicit type casting examples.The right hand side is smaller than the lefthand side
-
8/3/2019 Software Development Program
24/25
Casting / Conversion Explicit casting
When you want to assign a larger value to a smaller
value, you can not do it without explicitly casting itusing the cast operator. This conversion is sometimescalled narrowing conversion since you are explicitlymaking the value narrower to fit into the small size.
The syntax for explicit casting is:
target variable = (target) value;
-
8/3/2019 Software Development Program
25/25
Casting / ConversionNOTE:
When you explicitly cast large value to small value
some information may be lost. For example, whenfloating point value is assigned to an integer thefractional part is lost
int a = 5;
byte b = a;The second line will cause error. You can cast thesecond line like this using cast operator.
byte b = (byte) a;