0% found this document useful (0 votes)
62 views

TrainingMaterials Day2

This document provides an overview of topics to be covered on Day 2 of a programming course, including basic object-oriented programming concepts, C# syntax, data types, variables, operators, conditional statements, loops, functions, exception handling, arrays, classes, methods, and more. It introduces concepts like objects, classes, encapsulation, inheritance, and polymorphism. It also describes C# syntax elements like case sensitivity, line endings, and comments. Data types covered include value types, reference types, integers, floating point, decimal, boolean, char, and strings.

Uploaded by

Arindam Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

TrainingMaterials Day2

This document provides an overview of topics to be covered on Day 2 of a programming course, including basic object-oriented programming concepts, C# syntax, data types, variables, operators, conditional statements, loops, functions, exception handling, arrays, classes, methods, and more. It introduces concepts like objects, classes, encapsulation, inheritance, and polymorphism. It also describes C# syntax elements like case sensitivity, line endings, and comments. Data types covered include value types, reference types, integers, floating point, decimal, boolean, char, and strings.

Uploaded by

Arindam Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

Day2

o Basic OOP concepts


o Basic C# Syntax
o Comments
o Data Types
o Variables
o Operators
o Conditional Statements
o Looping Structures
o Functions
o Exception Handling
o Arrays
o Resizing Arrays
o ArrayLists & HashTables
o Generic Collections
o Classes and Objects
o Partial Classes
o Methods, Properties and Events
o Constructors
o Property Procedures
o Enumerations
o Reference vs. Value Types
o Structures
o Namespaces

Basic OOP concepts


Objects methods and properties
Languages c#, java

An object oriented program may be viewed as a collection of interacting objects, as opposed to


the conventional model, in which a program is seen as a list of tasks (subroutines) to perform

Objects, Class real world simulation


Differences between Object and Class
Encapsulation
Inheritance
Polymorphism

Object lifetime

Instance and Static members

Basic c# Syntax
Strongly type -
Case-sensitive
Line ends with semi-colon

using System;
class Hello {
static void Main() {
Console.WriteLine("Hello World");
}
}

Compilation (in the Console window)


csc Hello.cs
Execution
Hello

Comments
/* */ - multi line
// - single line
/// - XML documentation

Necessity of comments

/*
*
***************************************************************************
**
NAME:TaxDetails.aspx
PURPOSE:Create a page for Tax Details
REVISIONS:
Ver Date Author CR#/Release Description
--------- ------------ --------------- ------------
------------------------------------
1.0 22/01/2013 ABC Created Created
1.1 16/04/2013 ABC Modified Serial No not coming properly
solved the ST issue.
***************************************************************************
************************************************
*/

Comments in ASPX pages

Data Types

Value Types / Reference Types


Value types directly contain their data which are either allocated on the stack or allocated in-line
in a structure. Reference types store a reference to the value's memory address, and are allocated
on the heap.

Reference types can be self-describing types, pointer types, or interface types. Variables that are
value types each have their own copy of the data, and therefore operations on one variable do not
affect other variables. Variables that are reference types can refer to the same object; therefore,
operations on one variable can affect the same object referred to by another variable. All types
derive from the System.Object base type.

Integer Type

Floating point type

Decimal type

Boolean Type
Char type

Predefined Reference Type

using System;
class StringExample
{
public static int Main()
{
string s1 = a string;
string s2 = s1;
Console.WriteLine(s1 is + s1);
Console.WriteLine(s2 is + s2);
s1 = another string;
Console.WriteLine(s1 is now + s1);
Console.WriteLine(s2 is now + s2);
return 0;
}
}

Varibles

Variables are programming elements that can change during program execution. Theyre
used as storage to hold information at any stage of computation. As a program executes,
certain variables change to support the goals of an algorithm. The syntax of a variable
definition uses the following pattern:
Type Identifier [= Initializer];

Heres an example of a variable declaration without initialization:


char middleInitial;

You can subsequently assign a value to middleInitial like this:


middleInitial = B;

Alternatively, you can declare and initialize on the same line:


char middleInitial = B;

Object declaration
Customer cust = new Customer();

string thanks = Hey \Tony\.\r\nThanks for the great example!;


Escape sequences

Accessibility Levels -
Following are the five levels of access modifiers :-
Private : Only members of class have access.
Protected :-All members in current class and in derived classes variables.
Friend (internal in C#) :- Only members in current project have elements.
Protected friend (protected internal in C#) :- All members in current and all members in
derived class can access the variables.
Public :- All members have access in all classes and projects.

Operators

Unary Operators
Binary Operators
Ternary Operator
Other Operator

Unary Operator
Unary operators affect a single expression.
Plus,
Minus,
Increment (post & pre)
Decrement (post & pre)
Logical Compliment (A logical complement operator (!) inverts the result of a Boolean)
BitwiseCompliment ((~) inverts the binary representation of an expression)
byte bitComp = 15; // bitComp = 15 = 00001111b
byte byteResult = (byte) ~bitComp; // bresult = 240 = 11110000b

Binary Operators
Binary operators work with two operands. For example, a common binary expression
would be a + bthe addition operator (+) surrounded by two operands. The binary operators
are further subdivided into
arithmetic,
relational,
logical, and
assignment operators.

Arithmetic
multiplication *
Division /
Modulus %
Addition +
Substraction
Left Shift
Right Shift

The Left Shift Operator


To shift the bits of a number to the left, use the left shift operator ( <<). Heres an example.
uint intMax = 4294967295; // 11111111111111111111111111111111b
uint byteMask;
byteMask = intMax << 8; // 11111111111111111111111100000000b
The effect of this operation is that all bits move to the left the specified number of times.
High-order bits are lost. Lower-order bits are 0 filled. This operator can be used with the
int, uint, long, and ulong types.

The Right Shift Operator


The right shift operator (>>) shifts the bits of a number to the right. Here are some
examples:
uint intMax = 4294967295; // 11111111111111111111111111111111b
uint shortMask;
shortMask = intMax >> 16; // 00000000000000001111111111111111b
int intMax = -1; // 11111111111111111111111111111111b
int shortMask;
shortMask = intMax >> 16; // 10000000000000001111111111111111b
Given a number to operate on and number of digits, all bits shift to the right by the
number of digits specified. You can use the right shift operator on int, uint, long, and
ulong types. The uint, ulong, positive int, and positive long types shift 0s from the left.
The negative int and negative long types keep a 1 in the sign bit position and fill the
next position to the right with a 0.

Relational
Equal ==
No Equal !=
Less than <
Greater than >
Less than or equal <=
Greater than or equal >=

Logical
Logical operators perform Boolean logic on two expressions. There are three types of
logical operators in C#:
bitwise,
Boolean, and
conditional.

The bitwise logical operators perform Boolean logic on corresponding bits of two integral
expressions. Valid integral types are the signed and unsigned int and long types. C#
promotes byte to int, which is why the example in the prevous section worked. The
bitwise logical operators return a compatible integral result with each bit conforming to
the Boolean evaluation.

Boolean logical operators perform Boolean logic upon two Boolean expressions. The expression
on the left is evaluated, and then the expression on the right is evaluated. Finally, the
two expressions are evaluated together in the context of the Boolean logical operator
between them. They return a bool result corresponding to the type of operator used.

The conditional logical operators operate much the same way as the Boolean logical operators
with one exception: When the first expression is evaluated and found to satisfy the
results of the entire expression, the second expression is not evaluated. This is efficient
because it doesnt make sense to continue evaluating an expression when the result is
already known.

The Bitwise AND Operator


The bitwise AND operator (&) compares corresponding bits of two integrals and returns a
result with corresponding bits set to 1 when both integrals have 1 bits. When either or
both integrals have a 0 bit, the corresponding result bit is 0.

The bitwise OR operator (|) compares corresponding bits of two integrals and
returns a result with corresponding bits set to 1 if either of the integrals have 1 bits in that
position. When both integrals have a 0 in corresponding positions, the result is 0 in that
position.

Boolean AND
The Boolean AND operator (&) evaluates two Boolean expressions and returns true when
both expressions evaluate to true. Otherwise, the result is false. The result of each
expression evaluated must return a bool.

Boolean OR

The Boolean OR operator (|) evaluates the results of two Boolean expressions
and returns true if either of the expressions returns true. When both expressions are
false, the result of the Boolean inclusive OR evaluation is false. Both expressions evaluated
must return a bool type value.

The Conditional AND Operator


The conditional AND operator (&&) is similar to the Boolean AND operator (&) in that it
evaluates two expressions and returns true when both expressions are true. When the
first expression evaluates to false, there is no way the entire expression can be true.
Therefore, the conditional AND operator returns false and does not evaluate the second
expression. However, when the first expression is true, the conditional AND operator goes
ahead and evaluates the second expression. Heres an example:
bool inStock = false;
decimal price = 18.95m;
bool buy;
buy = inStock && (price < 20.00m); // buy = false
Notice that price < 20 will never be evaluated.

The Conditional OR Operator


The conditional OR operator (||) is similar to the Boolean inclusive OR operator (|) in
that it evaluates two expressions and returns true when either expression is true. When
the first expression evaluates to true, the entire expression must be true. Therefore, the
conditional OR operator returns true without evaluating the second expression. When the
first expression is false, the conditional OR operator goes ahead and evaluates the second
expression. Heres an example:
int mileage = 4305;
int months = 4;
bool changeOil;
changeOil = mileage > 3000 || months > 3; // changeOil = true

Notice that because mileage > 3000 is true, months > 3 will never be evaluated.
Assignment Operator
= += -= *= /= %= <<= >>= &= ^= |=

Ternary Operator
The ternary operator contains three expressions, thus the name ternary. The first expression
must be a Boolean expression. When the first expression evaluates to true, the value
of the second expression is returned. When the first expression evaluates to false, the
value of the third expression is returned. This is a concise and short method of making a
decision and returning a choice based on the result of the decision. The ternary operator is
often called the conditional operator. Heres an example:

long democratVotes = 1753829380624;

long republicanVotes = 1753829380713;

string headline = democratVotes != republicanVotes ?


We Finally Have a Winner! : recount();

Other Operators
C# has some operators that cant be categorized as easily as the other types. These include
the
is,
as,
sizeof(),
typeof(),
checked(), and
unchecked() operators.

Conditional Statements

If

if (Boolean expression)
[{]
true condition statement(s)
[}]

if (args.Length == 0)
{
Console.WriteLine(Invalid # of command line args);
}

If-then-else
if (args.Length == 0)
{
Console.WriteLine(Invalid # of command line args);
}
else
{
Console.WriteLine(You entered: {0}?, args[0]);
}
If-else-elseif
if (args.Length == 0)
{
Console.WriteLine(Invalid # of command line args);
}
else if (args.Length == 1)
{
Console.WriteLine(You entered: {0}?, args[0]);
}
else
{
Console.WriteLine(Too many arguments!\a);
}

Switch
switch (choice)
{
case A:
Console.WriteLine(Add Site);
break;
case S:
Console.WriteLine(Sort List);
break;
case R:
Console.WriteLine(Show Report);
break;
case Q:
Console.WriteLine(GoodBye);
break;
default:
Console.WriteLine(Huh??);
break;
}

Grouping case and goto statement


switch (choice)
{
case a:
case A:
Console.WriteLine(Add Site);
break;
case S:
Console.WriteLine(Sort List);
break;
case R:
Console.WriteLine(Show Report);
break;
case V:
Console.WriteLine(View Sorted Report);
// Sort First
goto case R;
case Q:
Console.WriteLine(GoodBye);
break;
default:
Console.WriteLine(Huh??);
break;
}

Looping Structures
While
Do
For
Foreach

foreach
foreach (type identifier in collection)
[{]
statement(s)
[}]
Statements goto. Break, continue, return

public static int Main(string[] args)


{
// other program statements
return 0;
}

ASSIGNMENT

Functions
Overview, difference with method

Exception Handling

Try/catch/finally

using System;
public class Exceptions
{
public static int Main(string[] args)
{
byte[] myStream = new byte[3];
try
{
for (byte b=0; b < 10; b++)
{
Console.WriteLine(Byte {0}: {1}, b+1, b);
myStream[b] = b;
}
}
catch (Exception e)
{
Console.WriteLine({0}, e.Message);
}
return 0;
}
}

Output:
Byte 1: 0
Byte 2: 1
Byte 3: 2
Byte 4: 3
Index was outside the bounds of the array.

Multiple Catch

using System;
using System.IO;
public class Exceptions3
{
public static int Main(string[] args)
{
int mySize = 3;
byte[] myStream = new byte[mySize];
int iterations = 5;
StreamWriter sw = new StreamWriter(exceptions.txt);
try
{
for (byte b=0; b < iterations; b++)
{
sw.WriteLine(Byte {0}: {1}, b+1, b);
myStream[b] = b;
}
}
catch (IndexOutOfRangeException iore)
{
Console.WriteLine(
Index Out of Range Exception: {0},
iore.Message);
}
catch (Exception e)
{
Console.WriteLine(Exception: {0}, e.Message);
}
finally
{
sw.WriteLine(Close);
sw.Close();
}
return 0;
}
}

Handling and Passing exceptions using throw

using System;
using System.IO;
public class Exceptions4
{
public static int Main(string[] args)
{
Exceptions4 myExceptionMaker = new Exceptions4();
try
{
myExceptionMaker.GenerateException();
}
catch (Exception e)
{
Console.WriteLine(\nNow processing Main() Exception:);
while (e != null)
{
11
Console.WriteLine(\tInner: {0}, e.Message);
e = e.InnerException;
}
}
finally
{
Console.WriteLine(Finally from Main());
}
return 0;
}

void GenerateException()
{
int mySize = 3;
byte[] myStream = new byte[mySize];
int iterations = 5;
StreamWriter sw = new StreamWriter(exceptions.txt);
try
{
for (byte b=0; b < iterations; b++)
{
sw.WriteLine(Byte {0}: {1}, b+1, b);
myStream[b] = b;
}
}
catch (IndexOutOfRangeException iore)
{
Console.WriteLine(
\nIndex Out of Range Exception from GenerateException: {0},iore.Message);
throw new Exception(
Thrown from GenerateException.,iore);
}
catch (Exception e)
{
Console.WriteLine(
\nException from GenerateException: {0}, e.Message);
}
finally
{
Console.WriteLine(Finally from GenerateException.);
sw.WriteLine(Close);
sw.Close();
}
}
}

Output
Heres the codes output:
Index Out of Range Exception from GenerateException: An exception of type System
.IndexOutOfRangeException was thrown.
Finally from GenerateException.

Now processing Main() Exception:


Inner: Thrown from GenerateException.
Inner: An exception of type System.IndexOutOfRangeException was thrown.
Finally from Main()
ASSIGNMENT

Arrays

Single Dimension, Multi-Dimension and Jagged Arrays


An array is a type that holds a list of objects.

Single-dimension arrays let you store and manipulate a list of objects. Every element is of
the same (or derived if applicable) type. Heres the basic syntax:

Type[] Array-Identifier [initializer] ;

e.g.
// uninitialized declaration
byte[] inputBuffer = new byte[2048];

// creates an array of 3 strings


string[] countStrings = { eins, zwei, drei };

Its common to use loops to access each element of an array. Heres an example using a
for loop:
for (int i = 0; i < countStrings.Length; i++)
{
Console.WriteLine(countStrings[i]);
}

Arrays are Zero based. Starting element is 0.

Array indexer can be used to access array data element, e.g.


countStrings[1] = two;

Arrays are reference types.


Assigning one array to another just
makes the variable assigned to contain an identical reference to the same object in
memory.

Multi-dimension array
A multidimension array differs from a single-dimension array in that it contains two or
more dimensions.

long [ , ] determinant = new long[4, 4];


int [ , , ] stateSpace = new int[2, 5, 4];

Jagged Array
The jagged array has characteristics of a single dimension array in that it is an
array of arrays.

for (int i = 0; i < monthlyVariations.Length; i++)


{
for (int j = 0; j < monthlyVariations[i].Length; j++)
{
Console.WriteLine(monthlyVariations[i][j]);
}
}
Resizing Arrays
After a C# array has been initialized, it cant change its size.
A collection class need to be used for greater flexibility

ArrayLists & HashTables

An array list is very similar to an array, except that it has the ability to grow. It is represented
by the class
System.Collections.ArrayList.

It is a collection, they could work with any type.


Automatic growth
Can hold items of different types
Any item in array can be accessed by Index value

If you try to add more objects to the ArrayList than permitted, then it will automatically
increase its capacity by allocating a new area of memory big enough to hold twice as many
elements as the current capacity, and relocate the objects to thisnew location.

ArrayList vectors = new ArrayList(20);


ArrayList vectors = new ArrayList(); // capacity of 16- If you dont specify the initial size, it defaults
to 16:

Hashtable provides way to access elements using a KEY, thus removing the index problem,
which may not be known always.

using System.Collections;

Hashtable myHash = new Hashtable();

if (myHash.ContainsKey(strUserID.ToLower()))
{
string values = Convert.ToString(myHash[strUserID.ToLower()]);
myHash.Remove(strUserID.ToLower());
myHash.Add(strUserID.ToLower(), value);
}

Generic Collections

Generic types allow you to parameterize your code and then use that code by filling in a
type parameter with whatever object type you want that generic type to work on.

A generic List

var letters = new List<string>();


letters.Add(Alpha);
letters.Add(Beta);
letters.Add(Charlie);
foreach (var letter in letters)
{
Console.WriteLine(letter);
}
Generics give you the benefits
better performance with value types,
greater type safety,
reduce the number of explicit conversions you need to make.

No Error when Employee added to Customer ArrayList


ArrayList customers = new ArrayList();
customers.Add(new Customer());
customers.Add(new Employee());
customers.Add(15.5f);
foreach (Customer cust in customers)
{
Console.WriteLine(cust.ToString());
}

Generic List will generate error when Employee object is getting added

List<Customer> customers = new List<Customer>();


customers.Add(new Customer());
customers.Add(new Customer());
customers.Add(new Employee());
foreach (Customer cust in customers)
{
Console.WriteLine(cust.ToString());
}

Boxing/Unboxing problem with ArrayList. A value type assigned to an ArrayList.


ArrayList myInts = new ArrayList();
myInts.Add(1);
myInts.Add(2);
myInts.Add(3);
foreach (int myInt in myInts)
{
Console.WriteLine(myInt);
}

Boxing permits any value type to be implicitly converted to type object or to any interface type
implemented by value type.
Boxing is a process in which object instances are created and copy values in to that instance.

Unboxing is vice versa of boxing operation where the value is copied from the instance in to
appropriate storage location.

Below is sample code of boxing and unboxing where integer data type is converted in to object
and then vice versa.
Dim x As Integer
Dim y As Object
x = 10

boxing process
y=x

unboxing process x = y
Using generics, you can make assignments in a strongly typed manner.

List<int> myInts = new List<int>();


myInts.Add(1);
myInts.Add(2);
myInts.Add(3);
foreach (int myInt in myInts)
{
Console.WriteLine(myInt);
}

Classes and Objects

Class, Object

Base Class, Derived Class, Sealed Class, Abstract Class, Nested Class, Partial Class, Static
Class

Base keyword
public class A
{
public A( int var )
{
this.x = var;
}
public virtual void DoSomething()
{
System.Console.WriteLine( "A.DoSomething" );
}
private int x;
}
public class B : A
{
public B() : base( 123 )
{
}
public override void DoSomething()
{
System.Console.WriteLine( "B.DoSomething" );
base.DoSomething();
}
}
public class EntryPoint
{
static void Main()
{
B b = new B();
b.DoSomething();
}
}

Accessibility Levels -
Following are the five levels of access modifiers :-
Private : Only members of class have access.
Protected :-All members in current class and in derived classes variables.
Friend (internal in C#) :- Only members in current project have elements.
Protected friend (protected internal in C#) :- All members in current and all members in
derived class can access the variables.
Public :- All members have access in all classes and projects.

Polymorphism
public class GeometricShape
{
public virtual void Draw()
{
// Do some default drawing stuff.
}
}
public class Rectangle : GeometricShape
{
public override void Draw()
{
// Draw a rectangle
}
}
public class Circle : GeometricShape
{
public override void Draw()
{
// Draw a circle
}
}

Sealed Class
C# offers the sealed keyword for the occasions when you never want a client to derive
from a
class. When applied to the entire class, the sealed keyword indicates that this class is a
leaf class.

Abstract Class
You cannot create an object of abstract class

Abstract class is designed to act as a base class (to be inherited by other classes).
Abstract class is a design concept in program development and provides a base
upon which other classes are built.

Abstract classes are similar to interfaces. After declaring an abstract class, it


cannot be instantiated on its own, it must be inherited.

In C# we have Abstract keyword.

Abstract classes can have implementation or pure abstract methods which should
be implemented in the child class.
They establish structure and meaning to code. This is possible because abstract classes have
information and behavior common to all derived classes in a framework. All common
functionalities are put in Abstract Class

public abstract class GeometricShape


{
public abstract void Draw();
}
public class Circle : GeometricShape
{
public override void Draw()
{
// Do some drawing.
}
}
public class EntryPoint
{
static void Main()
{
Circle shape = new Circle();
// This won't work!
// GeometricShape shape2 = new GeometricShape();
shape.Draw();
}
}

Nested class
Nested classes are classes within classes.
In sample below ClsNested class has a ChildNested class nested inside it.
PublicClassClsNested
PublicClassChildNested
PublicSubShowMessage()
MessageBox.Show(Hithisisnestedclass)
EndSub
EndClass
EndClass
This is the way we can instantiate the nested class and make the method call.
DimpobjChildNestedAsNewClsNested.ChildNested()
pobjChildNested.ShowMessage()

Static Classes
Normal classes can have instance and static members, but sometimes we need to create static
classes with only static members.
All members of the static class must be static.

public static class CustomMathLib


{
public static double DoAdvancedCalculation(
double param1, double param2)
{
return -1;
}
}

They are used when a class provides functionality which is not specific to any instance. In
short if you want an object to be shared between multiple instances you will use a
static/Shared class.
Following are features of Static/Shared classes:-
They cannot be instantiated. By default an object is created on the first method call to
that object.
Static/Shared classes cannot be inherited.
Static/Shared classes can have only static members.
Static/Shared classes can have only static constructor.

Partial Classes

The syntax identifying a partial type includes a class (or struct) definition with the partial
modifier. At compile time, C# identifies all classes defined with the same name that have
partial modifiers and compiles them into a single type. The following code shows the
syntax of partial types:

using System;
partial class Program
{
static void Main()
{
m_someVar = 5;
}
}
// Located in a different file
using System;
partial class Program
{
private static int m_someVar;
}

ASP.NET pages classes are partial classes


partial class _Default : System.Web.UI.Page
{
...
}

ASSIGNMENT
Create a Static Class and use its method and properties
Create a base Class and create a derived class with override methods

Methods, Properties and Events


Class methods, properties, events

Constructors
Constructors are called when a class is first loaded by the CLR or an object is
created. There are two
types of constructors: static constructors and instance constructors. A class can
have only one static
constructor, and it can have no parameters. The name of the static constructor
must match the
name of the class it belongs to. As with any other class member, you can attach
metadata attributes
to the static constructor.
Instance constructors, on the other hand, are called when an instance of a class
is creat
Property Procedures

Enumerations
An enum type is a list of strongly typed constant values. Just like a class or struct is used
to create custom reference type and value type objects, an enum allows you to create a
custom value type. They are meant to be reused across a program, so you typically declare
enum types at the namespace level.

enum Months { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec }

Months currentMonth = Months.Nov;

Reference vs. Value Types

Value types directly contain their data which are either allocated on the
stack or allocated in-line in a structure. Reference types store a reference to
the value's memory address, and are allocated on the heap. Reference types
can be self-describing types, pointer types, or interface types.

Variables that are value types each have their own copy of the data, and
therefore operations on one variable do not affect other variables. Variables
that are reference types can refer to the same object; therefore, operations
on one variable can affect the same object referred to by another variable.
All types derive from the System.Object base type.

Structures
Following are the similarities between classes and structures :-
Both can have constructors, methods, properties, fields,
constants, enumerations, events, and event handlers.
Structures and classes can implement interface.
Both of them can have constructors with and without parameter.
Both can have delegates and events.

Following are the key differences between them :-


Structure are value types and classes are reference types. So
structures use stack and classes use heap.
Structures members cannot be declared as protected, but class
members can be. You cannot do inheritance in structures.
Structures do not require constructors while classes require.
Objects created from classes are terminated using Garbage
collector. Structures are not destroyed using GC.

Namespaces

Namespace has two basic functionality:-

NameSpace Logically group types, example System.Web.UI logically groups our UI


related features.

In Object Oriented world many times its possible that programmers will use the same
class name.By qualifying NameSpace with classname this collision can be avoided.

Following are the differences between namespace and assembly :


Assembly is physical grouping of logical units. Namespace logically groups classes.
Namespace can span multiple assembly.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy