Vous êtes sur la page 1sur 78

Course No.

Course Name L T P Theory Sessional Practical Total


(Hrs) (Hrs) (Hrs) Marks Marks Marks Marks
Max Min Max Min Max Min
MCA-504 Elective II : EII(e) : 3 1 - 100 40 50 30 - - 150
.Net Technology

UNIT-I
Introduction to .NET Technology, Introduction to VB.NET, Software development and Visual Basic .NET, Visual Basic .NET
and .NET frame.

UNIT-II
Visual Basic fundamentals: The Visual Basic .NET Development Environment, The element of VB.NET, VB.NET operators,
Software design, Conditional structure and control flow, Methods.

UNIT-III
Classes and Objects: Types, Structure and Enumeration, Classes, Interfaces, Exception handling and Classes, Collections,
Arrays and other Data Structure.

UNIT-IV
Advance design concepts, Patterns, Roles and Relationships, Advanced Interface Patterns: Adapters and Delegates and Events
Data Processing and I/O.

UNIT-V
Writing Software with Visual Basic .NET, Interfacing with the End User, Introduction to ASP.NET and C#.NET and their
features.

BOOKS
1) Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002 Edition).
2) Rox “Beginner and Professional Edition VB.NET” Tata Mcgraw Hill.
3) Steven Holzner “Visual Basic .NET Black Book” Wiley Dreamtech Publication.
4) Alex Homer, Dave Sussman “Professional ASP.NET1.1” Wiley Dreamtech
5) Bill Evzen,Bill Hollis “Professional VB.NET 2003” Wiley Dreamtech
6) Tony Gaddis “Starting Out VB.NET PROG.2nd Edition” Wiley Dreamtech
7) Chris Ullman, Kauffman “Beg. ASP.NET1.1 with VB.NET 2003” Wiley Dreamtech
8) Chris Ullman, Kauffman “Beg ASP.NET1.1 with VC#.NET 2003” Wiley Dreamtech
ITM-MCA
MCA
Lecture Plan
Subject: .Net Technology Subject Code: 504 MCA
Credits: Lecture: 3 Tutorial: 1 Practical:
Subject Teacher(s): Department: MCA

1. Aim of teaching the subject:


UNIT - I

1) The first unit is not so much about Visual Basic .NET as it is about programming in general and programming
in .NET in particular. The Lecture takes you through ages of procedural and structured programming, and into
the object− oriented paradigm. We will discuss modularity, class cohesion, and related topics.
The largest section in this Lecture goes into what makes a pure object −oriented language. It discusses the so−
called "three corners of OO": inheritance, polymorphism, and encapsulation. It also points out how many constructs,
like encapsulation, are rooted in programming models, pre− OO. Most important is that you'll see how Visual Basic
now fits the bill as an extremely powerful and pure OO language.
The CHAPTER covers the differences between object −oriented programming (OOP) and object− based
programming (OBD). There is also a discussion about frameworks.
The concept of patterns in software development is a very important subject. The subject of patterns is introduced in
this chapter.

2) In this lecture we cover CLR (Common language Run time) and goes into Microsoft intermediate language, how
your application code gets packaged into assemblies, and how the runtime locates and runs your code.
Also we need to know about the assembly cache, side− by −side execution, the Common Language Specification,
and .NET security.

UNIT - 2

3) This lecture aims at making you productive with Visual Studio .NET as quickly as possible. You'll learn about
the important features, windows, and tools in Visual Studio, and how to load the Visual Studio solution and projects
and provide base class library

4) The first part to turn to for coverage of certain constructs. It also provides information on .NET code writing
style, such as whether to use Hungarian notation (which is discouraged), what should be cased in camel casing, and
what should be cased in Pascal casing.
This lecture also goes into the various declaration spaces and contexts of a .NET program. For example, it covers
the compiler options (Option Explicit, Option Strict, and Option Compare), namespace declarations and the
concept of namespaces, class characteristics, and the class members. This lecture covers variables, constants,
important keywords, conversion, scope, and lifetimes.

5) IN this lecture we focus on VB.NET operator in details. We will discuss operator precedence, arithmetic &
logic operator. Most important is operator over loading
6) This lecture deals
exclusively with flow− control, iteration, and the conditional constructs. Without these fundamental facilities we
cannot program any logic into our software. I cover Go to and other conditional function like choose, IIF, Switch
in this lecture.

7) Methods are what make your objects work. They come in two flavors: functions and sub− routines. The latter is
known as a Sub in Visual Basic. Functions return values while Subs do not. This CHAPTER deals with everything
you need to know about methods. It deals with method characteristics, parameter lists, return values, pass− by−
value, and pass by reference.
This lecture also covers the polymorphic facilities of methods, such as overloading, overriding and shadowing. It
explains the difference between static or shared methods, and instance methods, and it explains the purpose of
abstract, virtual, and final methods.
This lecture also introduces exception handling, a precursor to 11, which covers exception handling exclusively and
in much more depth.

UNIT - 3

8) Visual Basic .NET and the .NET Framework provide outstanding support for value types, structures or structs,
and enumerated types (enumerations or enums). This lecture covers the object reference model, the difference
between the objects that live on the stack (a more efficient region of memory), and the objects that live in heap
memory.
The lecture explains the concept of boxing, how objects get moved between the stack and the heap.

9) This lecture covers all aspects of classes and objects, from class characteristics and how classes are constructed
and relate to each other, to how classes become objects.
I also cover modeling in depth in this lecture and provide a small introduction to UML. This section includes a
guide to the UML symbols used in a number of class diagrams throughout the book.
This lecture also covers inheritance in detail, and explains the differences between inheritance, aggregation, and
composition. We investigate how to construct base classes, abstract classes, and how to decide how classes should
relate to each other. This lecture also covers static classes and how to seal a class.

10) This lecture cover introduction of Interfaces and understand what interfaces are, how they are used, and why
they are so important.
The lecture details how interfaces provide the polymorphism so important to object− oriented software. It not only
goes into interface factoring, how interfaces are constructed and so on, but it sets you up to understand the more
complex programming concepts, like method indirection, delegation and Delegates, wrapping, and varying
implementation.
The lecture covers everything you need to know about working with interfaces from declaration and definition to
implementation, instantiation, and bridging.

11) In this lecture understanding the exception −handling it is important. It not only covers the ins and out of using
exception handling in your code, guarding code in Try Catch Finally constructs, but also shows you how to create
custom exception handling objects.

12) Data structures and collections are where you store the data you work with in your programs. They include
arrays, lists, stacks, and queues. This lecture is extensive and deals with the specifics of the most important data
structures. The first part of the lecture deals with declaring and using the likes of stack objects and queues. It also
introduces the key interfaces that are implemented in collection classes, which provide the support for iteration and
framework wide constructs.
This lecture focuses onto arrays. It looks at how to fill arrays, access array elements, iterate over arrays, and how to
pass arrays to methods. Later in this lecture, we look at sorting and investigate how to write sorting algorithms like
quicksort, bubble sort,
and so on. There are two motives behind the work with sorting algorithms. First, they cover important method
construction issues, like method decomposition and how to divide Chapters of work in your algorithms. Second,
these sections bring us down from the lofty abstractions of object and classes in the previous lectures.

UNIT - IV

13) Patterns are as critical to object oriented software as blueprints are to architects. This CHAPTER investigates
several of the most important patterns in OO. These include the Singleton pattern, the Bridge and Strategy patterns
(which make extensive use of interfaces), and the State pattern.
The lecture specializes in the Composite pattern and looks at composition and aggregation in some detail. It covers
the creation, from design and specification, of a full −blown linked list class that you can emulate and incorporate in
your code. To iterate the list I show you how to implement the collection interfaces, IList, ICollection, and
IEnumerable. You will also learn how to build a collection class and an iterator for traversing it by implementing
the IEnumerator interface.

14) This lecture tackles the subject of Delegate objects, Adapters and delegation head−on. This subject has its
roots in Visual J++ and is one that gives programmers a lot of trouble. Few constructs create as much confusion and
debate as the Delegate class and how to use it.
We examine how Delegates are used as object −oriented function pointers. While I touch on the subject of callbacks
and asynchronous programming, this lecture deals mainly with simple method pointing.
It takes recursion used with the sort methods in previous and shows how to replace it with Delegates.

15) Manipulating data and getting data into and out of your application are other core requirements for you to
master. This covers string handling and I/O, and several important namespaces and classes that cater to I/O.
After discussing string manipulation and regular expressions, the lecture goes into an extensive investigation of all
the file, directory, and I/O classes. These include the various stream classes, and text readers and writers.
The lecture wraps up with a discussion of using the XML reader and writer classes, and a discussion of object
serialization using XML.

UNIT - V

17) In This lecture we develop application in vb.net

18) This lecture contain introduction of ASP.NET. We also cover some advanced feature of ASP.NET. We learn page life
cycle of web application. Validation and rich control, and Introduction of master page, configuration management. ASP.NET
have various controls like custom control and user control

19) This lecture covers all feature of C# and discuss oop’s concept regarding c# and learn how to use c# in ASP .NET code
.

2. Lecture Plan:

Sr. Contents Ai Hours Starting/


No. m Exp Co Completion
e n date
t
.
Unit-1 · Introduction to .NET Technology [T2-P25] 1 01
01
· Introduction to VB.NET [T3-P25] 2 01
· Software development and Visual Basic .NET [T1-P3]
· Visual Basic .NET and .NET frame [T1-P25].

No. of Tutorial : (1)


Text Book:

T1 -Thuan Thai & Hang Lam“.NET Framework Essential”, OREILLY,


T2 - Alex, Homer, Rob, Brian, Karli Watson, Richard Anderson” Professional
ASP.NET 1.1”, WROX.
T3- Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata
McGraw-Hill (2002 Edition).
Reference:

R1-Requirement of .NET Framework in current Scenario Satyendra Sharma ,


R2-Exploring cross language Independency in .NET Framework
Mohammad Zakir Hossain Sarkar, Shaila Rahman

Web Resources :

http://www.startvbdotnet.com
Unit-2 · The Visual Basic .NET Development Environment] [T1-P61 3 01
· The element of VB.NET [T1-P91] 4
· VB.NET operators [T1-P159] 5 01
· Software design [T1-P341] 6
· Conditional structure and control flow [T1-P195]
· Methods [T1-P227] 7 02

No. of Tutorial : 1

Text Book:
T1 - Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata
McGraw Hill (2002 Edition).

Reference:
R1 - Steven Holzner “Visual Basic .NET Black Book”

Web Resources :
http://www.startvbdotnet.com

Programming Task :
· Create a windows application using VB.NET tool.
· Create a grid view on a page and fill them

Unit-3 · Class, Object [T1-P341] 9 01


· Structure and Enumeration [T1-P297] 8
· Interfaces [T1-P405] 10 01
· Abstract, Polymorphism, [T2-P173]
· Exception handling [T1-P437], [T2- P 207] 11 01
· Collections, Arrays and other Data Structure [T1-P 475,] 12 01
[T2- P 295]

No. of Tutorial : 1

Text Book:

T1 - Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata


McGraw Hill (2002 Edition).
T2 - Andrew Troelsen “Pro VB 2008 and the .NET3.5 Platform”, Apress
T3 - Bill Hamilton & Matthew MacDonald“ADO.NET IN A NUTSHELL”,
OREILLY.

Reference:
R1- “Developing & Implementing Web Application with Visual C# .NET AND
Visual Studio .NET”, Ben Albahari,
R2- Peter Drayton & Brad Merrill “C# Essential V”, OREILLY, Christian
Nagel,
R3- Bill Even, Jay, Morgan, Karli Watson, Allen Jones “C# 2005”, WROX.
R4- Steven Holzner “Visual Basic .NET Black Book”

Web Resources :
Unit-4 · Advance design concepts :Patterns, Roles and Relationships [T1- 13 01
P553]
· Adapters and Reader [T1-P609] 14 01
· Delegates and Events [T1-P632]
· Data Processing and I/O.[T1-P657] 15

No. of Tutorial : 1

Text Book:

T1- Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata
McGraw Hill (2002 Edition).

Reference:
R1- Tom Fischer, John Slater, Pete Stromquist, Chaur G. Wu “Professional
Design Patterns in VB .NET: Building Adaptable Applications” Apress

Web Resources :
http://www.dofactory.com

Programming Task :

Implement a design Pattern in Programming


Unit-5 · Writing Software with Visual Basic .NET 17 01
· Interfacing with the End User (T1-P.755) 01
· Introduction to ASP.NET [R3] 18 02
· C#.NET and their features [R4]. [T2-P30] 19 02

No. of Tutorial : 1

Text Book:
T1 - Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata
McGraw Hill (2002 Edition).

Reference:
R1 - Albahari, Peter Drayton & Brad Merrill “C# Essential”, OREILLY.
“Developing & Implementing Web Application with Visual C# .NET AND
Visual Studio .NET”
R2 - Alex, Homer, Rob, Brian, Karli Watson, Richard Anderson” Professional
ASP.NET 1.1”, WROX.
R3- Bill Evjen, Scott, Devin Reader, Farhan, s.srinivas “Professional
ASP.NET 2.0”, WROX.
R4- Bill Even, Jay, Morgan, Karli Watson, Allen Jones “C# 2005”, WROX

Web Resources :

Programming Task :
· Create web pages
· Create a Login Page using ASP.NET & C#
· Apply navigation on all pages.
· Fill grid view using ADO .NET
· Applying State management on all pages.
· Use authorization and authentication in application

Augmentation Course-
01
1. RDBMS Concept
2. SQL SERVER 01
3. ADO.NET
4. Introduction Of UML 01
5. Concept of Web Applications
6. State Management

Web Reference-

3. Remarks:
Prepared By: Approved By:

Sign. Sign.

(i) Periods approximately required for completing the subject are 19 + 3 = 22.
(ii) It seems that
subject may be required extra classes, if required then schedule the extra classes.

Lecture Number : 1
BY :
Reference : 1. “Professional ASP.NET 1.1”, WROX, Alex, Homer, Rob, Brian, Karli Watson, Richard
Anderson. Chap-2
2. “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-1, 2

Contents of the Lecture

1. Client server Architecture


2. 1- tier, 2-tier, 3-tier, N-tier, Architecture
3. DLL, Exe, introduction
4. Introduction of frame work
5. Difference between VB and VB.NET

Client server Architecture –


Now day’s applications are developed in client server base technology. In this technique one machine
work as client & another machine is work as server. In internet environment first request generate by
client and server response on the request.

1- Tier – In this type of architecture all the three parts or components is reside on single machine, feasible
for you for developing single client application. If the number of client increases this
architecture will not be feasible .
UI
+
Logic
+
DataBase

2- Tier – In this architecture the database shifts on a centralized location and the user interface(UI) and
logic shifts on all the client system. Which interacts with the centralized database feasible in the
development of application used under banks, shopping Malls, Hospital etc.
The problem in this model is whenever modifications made in application part that requires to
be reinstall on the client machine.
UI
+ Database
Logic

3-tier – In 3-tier architecture the user interface (UI) ,Logic, Database are scattered on multiple systems.
Where only the UI resides on the client systems.

UI

Logic
Database
UI

This architecture is feasible when we have huge number of clients using the application eg:- Internet

DLL- A DLL (Dynamic Link Library) is a file that can be loaded and executed by programs dynamically.
The main advanatage in using DLL is several can use the same DLL during their execution.

Use of DLL (Dynamic Link Library)

Here are the key points that will guide you in understanding DLL.
· When we want to hide our code from the user then we make DLL (Dynamic Link Library) and add
these in other application now no body can open this.
· When we want to use same code in different applications (REUSABILITY) then we make DLL of
that code and add that code in other applications.
· When you want to use Functions of C# in Vb.net then you will make DLL of C# and add this
library in VB.net and can easily use its functions.
Examples:
There are many Examples of DLLs in .net. You are familiar with different DLLs like

System.Data
System.Drawing
System.Globalization

Now here System is a DLL and further are its classes. We can make classes in a class and make functions
in class like

System.Data.SqlClient
SqlClient is a class in Data Class.
System.Data.SqlClient.SqlConnection

Now in this sqlconnection is a function of class sqlclient. We all know that we can just use these functions
but can’t see there code. So this is a very useful concept.

Exe – It is independent and single use and you can't create object.

Introduction of frame work – The Microsoft .NET Framework is a software framework that can be
installed on computers running Microsoft Windows operating systems. It includes a large library of coded
solutions to common programming problems and a virtual machine that manages the execution of
programs written specifically for the framework. The .NET Framework supports multiple programming
languages in a manner that allows language interoperability, whereby each language can utilize code
written in other languages; in particular, the .NET library is available to all the programming languages
that .NET encompasses.
The .Net Framework

Lecture Number : 2
BY :
Reference : 1. “Professional ASP.NET 1.1”, WROX, Alex, Homer, Rob, Brian, Karli Watson, Richard
Anderson. Chap21
2. “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-2

Contents of the Lecture


Introduction .NET Technology
Manage code – That code own under CLR
Unmanaged code – Outside the environment
CLR –
· Manage & unmanaged code
· MSIL (Compiler/Interpreter)
· MSIL – IL-JIT (Twice compilation)
· Assembly – Physically group of logical unit
· CTS, CLS, GC, GAC. etc.
· Name space – Logically groups classes.
· Side by side executions

Why we required frame work.


Problem of prior development
DLL- Problem
Versioning problem

In introduction of frame work we detailed study of CLR. CLR provide run time environment. CLR has
done late of function. Which include GC, GAC, CL, CTS?
GC- CLR automatically free memory occupied by object.
GAC- Global Assembly Cache where use kept shared assembly.
CTS – Common type system. It is provide common type data it is help full for multi lingual supper system
int.
CLS – Common
language specification.
Side by side executions -Two processes run (diffident) under same system and same process.
DLL –
Versioning –

Lecture Number : 3
BY :
Reference : 1. “Professional ASP.NET 1.1”, WROX, Alex, Homer, Rob, Brian, Karli Watson, Richard
Anderson. Chap-2
2. “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-2

Contents of the Lecture

CLR
Value type or reference type
Strong Name
Boxing & unboxing
Architect of frame work
Value type – Value type stores is value directly stored in starch.
Reference type – Reference type stores a reference to the value stored in managed help.
Boxing– Boxing is converting a value type to a reference type.
Unboxing – Occurs memory is copied from the memory heat to starch.
Strong Name – A name consist of an assembly identify- its simple text name, version number and culture
information.
Type safe – C# is type safe due to -
Check away range
Reference parameter
Automatic GC
Overflow checking arithmetic opens.

Architecture of frame work –


VB C#J# C++
CLS
ASP Windows
Form
ADO.NET & XML
BCL
CLR
OS

Introduction of VB.NET

Compare with VB.NET & VB

Inline Code – Inline code written along side the HTML in a page.

Code behind – Code behind is code written in a separate file and referenced by the .aspx page.

Software Development & VB .NET

Lecture Number : 4
BY :
Reference :
1. Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002 Edition). Chap-3

Contents of the Lecture


Visual Studio IDE: - VB.NET provide default layout of IDE. IDE is in targeted development
Environment IDE provide some resources the are.
Auto hides – This is new feature in VB Studio that instructs the IDE to hide away the window you are not
currently using.
Dockable or floating window
Internet Explorer Menu Bar –
Server explorer – Crystal service, Message queries, event logs, performance counter loaded modules,
process, SQL server data Management data, web service data structure.
Resource view –
Tool Box – Tool box divided in to several sections as a tab lead layout they are –
Data – Contain data control as data set and data view.
Component – Times
Window form –
Clip bound ring –
General –
Macro explorer – Provide more control over the IDE than the tools, Option facility.
Objects Browser – The object Browser is one of the most important windows you will access during the
lifetime of development project.
Task list –

Lecture Number : 5
BY :
Reference :
1. Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002
Edition). Chap-
2. Rox “Beginner and Professional Edition VB.NET” Tata Mcgraw Hill. Chap-
3. Steven Holzner “Visual Basic .NET Black Book” Wiley Dreamtech Publication. Chap-

Contents of the Lecture

· Command window
The Command Window is another imperative feature of the new Visual Studio .NET IDE. The Command
Window has two views, Command and Immediate.
Command Mode Lets you execute Visual Studio Commands without using the IDE menu system.
(The illustration shows execution of the File.AddNewProject command, which is the command
behind the File menu item New, Project.)
Immediate Mode Used for debugging, expression evaluation, and variable modification. If you are
familiar with Visual Studio 6, then you'll recognize that this window includes the same functionality
as the VS 6 Immediate debugger window.
Both views in the Command Window support Intellisense and Autocomplete.

· Out put window


The Output Window
displays build/compiler or diagnostic information depending on the mode it is in. During
a build of a project or solution, the window is used to communicate build and compile information. In Debug
mode, during processing, the Output Window displays libraries loaded, return codes, and various details being
emitted from running code. For example, a special diagnostics Debug class.

Find Results
The Find Results windows (primary and secondary ones) display the results for "search and rescue"
operations launched from the sophisticated Find and Replace dialog box. Find and Replace is accessed from
the Edit, Find and Replace menu option. From here you can search for tokens, symbols, character strings with
standard pattern−matching, regular expressions, and wildcards.
The results of your searches are displayed in the two Find Results dialog boxes and you can search in various
places for your targetopen documents, projects, and folders.

Dynamic Help and Search


Dynamic Help is one of the most useful features of this IDE (see Figure 3−1). Simply place your cursor on an
element of your code (such as a class name or a method) and Dynamic Help finds and displays a link to the
resource in the Visual Studio help system.
Another important feature is the help system's Search facility, which comes equipped with a Help Filter. It
will save both time and resources, filtering your help material to just Visual Basic and related information.

Lecture Number : 6
BY :
Reference :
1. “Complete ReferencrVB.NET 2.0”, Tata McGraw Hill, Jeffery R. Shapiro
2. “Visual Basic .NET Black Book”, Paraglyph Press, by Steven Holzner

Contents of the Lecture

Creating a Visual Basic .NET solution –


Creating a new solution is straightforward. Go to the File menu and select New, Blank Solution from the
menus.
This topic better understand by either by PPt or lab.

Creating new project –

The Visual Basic projects you can create are as follows:


· Windows
Application Windows standard thick client applications based on forms (EXE)
· Class Library For individual classes or collections of classes (DLL)
· Windows Control Library Controls and components for Windows Forms (classic)
ASP.NET Web Application ASP.NET−based application composed of static or dynamic HTML
pages
·
ASP.NET Web Service For Web services to be used by clients communicating over the HTTP
protocol
·
· Web Control Library Web−based controls for ASP.NET applications
· Console Application Your standard Console application
· Windows Service Create Windows services
· Empty Project Empty Windows application project
· Empty Web Project Empty Web server−based application.

Base Class Library – Net framework provide a huge No. of reference types, static or shared, classes,
Interface and value types- built in fundamental data type such as ordinal part and character type that allow
you to build functionality and develop solid application and service.
There are same file extensions used with the Visual Basic project.

Data type –
Float – singe, Double decimal
Type conversion
Variable & constant
This topic better understand by either by ppt or lab.

Lecture Number : 7
BY :
Reference :
1. “Complete ReferencrVB.NET 2.0”, Tata McGraw Hill, Jeffery R. Shapiro. Chap- 5
2. “Visual Basic .NET Black Book”, Paraglyph Press, by Steven Holzner. Chap- 2

Contents of the Lecture


VB.NET Operators – An operator perform an operation an one or two operands.

Operand – An operand can be single value or an entire expression which should be enclosed in
parenthesis for clarify and operator classify of in to their specific function:-

Arithmetic + - * / \ Mod ^
Relational

Assignment =, + =, - = * \ = & / =, ^ =, & =

Concatenation C &

Bitwise

Introduction of Control Structures –


The sequence structure – The default of all .NET language in which instruction is executed in
sequence as they are written.
The decision structure – If statements there control construct interrupt sequence and transfer
control to another location in eth program.
The repetition – While, Do, For (Loop) this structure also known as iteration.

Detail study all control structure with example.

Lecture Number : 8
BY :
Reference : “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-6

Contents of the Lecture


In this lecture use will discuss about software Design, conditional structures & control flow.
All control structure we are discuss previous lecture.
In the software design process it is imperative to design, Model and fully consider your algorithm before
you code it, when you are constructing code, a number of formal "notation" allow you to sketch out a
design. These include the following –
Step Form notation
Pseudo code
Nassi- Schneider man charts
Flow Charts

Lecture Number : 9
BY :
Reference : Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002
Edition). Chap-7

Contents of the Lecture


Method – A method is a unit of functionality, an operation, within a class or an object.
A method is the
encapsulation of specific blocks of functionality and date with is a class, no matter whether that method
can be summoned or in void statically (shared) or dynamically through. Object creation and subsequent
collaboration with that object.
Type of Method –
Accessory methods – is used to access information from another object get method.
Modification method – It is called set method. Lets you manipulate an object get method.
Synchronous us asynchronous method calls –
Method Data –
Global
Local

The following are the access modifiers are available in .net framework
1. Public
2. Private
3. Friend (in C# it is known as internal)
4. Protected
5. Protected Friend
The main purpose of using scope modifiers is providing Security to the applications. when you want make
an assembly that can be used by various people in various applications on different computer then you
want that member of assembly must be have some functions may be important not to show or access
outside the assembly and same not
Here i will explain the types one by one.
1. PUBLIC
As the name specifies It can be accessed from anywhere. If a member of a class is defined as public then
it can be access
anywhere in class as well as outside the class. Thus other objects can access can modify the public fields
and can change
their values. example
public str as string
public myfunciton () as integer
-- define your function here
end function

2. PRIVATE
As the name suggests, it can't be access outside the class. Its the private property of class and can be
access only by the
members of the class.
example
Private str as string
Private myfunction() as integer
-- define your function here
end function
3. FRIEND
Friends can be accessed by all classes within assembly but not from outside the assembly.
example
Friend sub myfunction()
-- define procedure here
end sub
4. PROTECTED
Protected variables can be used within the class as well as the classes that inherit this class.
Example
Protected Myfunction() as integer
-- define function here
end function
5 PROTECTED FRIEND
The Protected Friend can be accessed by Members of the Assembly (Friend) or the inheriting class
(Protected).
Example
Protected Friend Myfunction () as integer
-- define your function here
end function
Other Windows Applications

Lecture Number : 10
BY :
Reference : C# 2005” , WROX , Christian Nagel, Bill Evjen, Jay, Morgan, Karli Watson, Allen Jones.

Contents of the Lecture


Polymorphism –
Polymorphism is one of the crucial features of OOP. It means "one name, multiple forms". It is also
called as Overloading which means the use of same thing for different purposes. Using Polymorphism we
can create as many functions we want with one function name but with different argument list. The
function performs different operations based on the argument list in the function call. The exact function
to be invoked will be determined by checking the type and number of arguments in the function.

Final methods (Not overridable)

Overriding method (Overridable)

Virtual methods (Overridable)

Abstract Methods (Mustoveride)

Overloading methods (overloads)

Shadow methods - (shadows)


When global and local variable in the same name. the local varibale in a method or function which use to
override the global is called the shadowing. I.e. the Global variable is being shadowed by the local
variable

Shared Methods
In VB.NET we have a better alternative. Not only can a class have all the regular methods and properties
we’ve seen so far – methods and properties only available after creating an instance of the class – but they
can also have methods that are available without creating an instance of the class. These are known as
shared methods.
These methods are also known as static methods or class methods in other languages.
A shared method is not accessed via an object instance like a regular method, but rather is accessed
directly from the class. The following is a simple example of a shared method:
Public Class Math
Shared Function Add (By Val a As Integer, By Val b As Integer) As
Integer
Return a + b
End Function
End Class
We can use this method – without instantiating a Math object – as follows:
Dim result As Integer
result = Math. Add (5, 10)
Notice how, rather than using an object variable, we use the actual class name to reference the method.
With a normal method this would result in a syntax error, but with a shared method this is perfectly
acceptable.
Shared methods can also be accessed via objects just like regular methods, but their most common use is
to provide functionality without the requirement for creating an object. In fact, when a shared method is
invoked, no object is created – the method is called directly, much like a procedure in a Module.
Shared methods can also be overloaded just like regular methods, so it is quite possible to create a set of
variations on the same shared method, each having a different parameter list.

Math class – System math.

Properties – A property is a construct that provide a well defined interface for value retrieval.
Read only - Use get & get methods
Write only - Use get & set methods
Lecture Number : 11
BY :
Reference :
1. C# 2005” , WROX , Christian Nagel, Bill Evjen, Jay, Morgan, Karli Watson, Allen Jones.
Chap-2,3
2. “C# Essential V” , OREILLY , Ben Albahari, Peter Drayton & Brad Merrill. Chap-2

Contents of the Lecture

Introduction to exception Handling –


When error carries in our application development (during coding) use handle or remove error through
same techniques. There are same reasons to occur try catch clocks –
Syntax
Runtime
Logic exception
Custom exception
Type’s structure and enumeration -
Value types –
Boxing - Convert a value type to a reference type.
Unboxing – Reference type of value type.
Structure –
Structure behavior
Nested structure
Structure constructors
Enumeration –
Brief idea about –
Classes –
Object –

Class - It's easy to create classes and objects in Visual Basic. To create a class, you only need to use the
Class statement, which, like other compound statements in Visual Basic, needs to end with End Class:
Public Class DataClass

End Class
This creates a new class named Data Class. You can create an object of this class, data, like this—note
that you must use the New keyword to create a new instance of a class:
Dim data As New DataClass()
Lecture Number : 12
BY :
Reference :
1. C# 2005” , WROX , Christian Nagel, Bill Evjen, Jay, Morgan, Karli Watson, Allen Jones.
Chap-2,3
2. “C# Essential V” , OREILLY , Ben Albahari, Peter Drayton & Brad Merrill. Chap-2

Contents of the Lecture


Classes and Objects
We've already become familiar with the idea behind classes and objects, as discussed in Chapter 2. The
idea is that classes are a type, and objects are examples or instances of that class. The relationship between
classes and objects is much like the relationship between cookie cutters and cookies—you use the cookie
cutter to create new cookies. Just think of the numeric data types like Integer, which is a type, and a
specific integer variable, myInteger233, which is an instance of that type. In fact, the Integer type is a
class in Visual Basic, and variables of that type are in fact objects.
It's easy to create classes and objects in Visual Basic. To create a class, you only need to use the Class
statement, which, like other compound statements in Visual Basic, needs to end with End Class:
Public Class DataClass

End Class
This creates a new class named DataClass. You can create an object of this class, data, like this—note
that you must use the New keyword to create a new instance of a class:
Dim data As New DataClass()
You also can do this like this:
Dim data As DataClass = New DataClass()

Exception handling- Exception handling is an in built mechanism in .NET framework to detect and handle
run time errors. The .NET framework contains lots of standard exceptions. The exceptions are anomalies that
occur during the execution of a program. They can be because of user, logic or system errors. If a user
(programmer) do not provide a mechanism to handle these anomalies, the .NET run time environment
provide a default mechanism, which terminates the program execution.

VB.NET provides three keywords try, catch and finally to do exception handling. The try encloses the
statements that might throw an exception whereas catch handles an exception if one exists. The finally can be
used for doing any clean up process.

The general form try-catch-finally in VB.NET is shown below.


Try
' Statement which can cause an exception.
Catch x As Type
' Statements for handling the exception
finally

COLLECTIONS

Collection Classes
==============================
i) ArrayList
ii) HashTable
iii)SortedList
iv) Queue and Stack

Collection Interfaces
==============================
i) IEnumerable
ii) IEnumerator And IDictionaryEnumerator
iii)ICollection
iv) IList
v) IDictionary

Members of IEnumerable
==============================
i) Current () : Returns the current object in the collection.
ii) MoveNext() : Used to move the position of the enumerator to the next item in the
collection.
iii)Reset() : Used to reset the position of the iterator to the first element of the collection.
Note: The IEnumerable interface is associated with IEnumerator.
====
Methods of IEnumerable
==============================
IEnumerable interface has one method.
i) GetEnumerator():It provides a forward-only read-only cursor for a set of items.

Members of ICollection
==============================
i) Count() : Used to get the number of items in the collection.
ii) CopyTo() : Used to copy the collection items to an array starting at a specified position in
this array.
iii)IsSynchronized and SyncRoot are used to set and get the synchronization object and status of the
collection.
Note: The ICollection interface derives from the IEnumerable interface so it inherits the GetEnumerator
method.
====

Members of IList
===================
===========
i) Item() : Used to get an object from a collection at a specified index.
ii) Add() : Used to add an item to the end of the list.
iii)Insert() : Used to insert an item into the collection at a specified position.
iv) Remove() : Used to remove an item from the collection.
v) RemoveAt() : Used to remove an item from the collection at a specified index.
vi) Contains() : Used to find out whether an item is contained in the collection.
vii)IndexOf() : Used to get the index of an item within a list.
v) Clear() : Used to remove all items from the collection.

Property of IList
==============================
i) IsReadOnly() : Determine if a list is read-only.
ii)IsFixedSize() : Determine if a list is of fixed size.
Note: The IList interface inherits the members of both ICollection and IEnumerable.
====

Members of IDictionary
==============================
i) Item() : Used to get an item from the collection based on its associated key.
ii) Add() : Used to add an item into the collection by passing in the key and value.
iii)Remove() : Used to remove an item from the collection by passing the key of the value.
iv) Keys()&Values() : Used to get a collection of all keys and values in this dictionary.
v) Contains() : Used to find out whether a key is associated in a collection.
vi) Clear() : Used to remove all items from the collection.
vii)GetEnumerator() : Used to get a specified enumerator of IDictionaryEnumerator.
Note:
====
The IDictionary interface derives from the ICollection interface so it inherits all of
its methods and properties, as well as those of the basic interface IEnumerable.

Members of IDictionaryEnumerator
==============================
i) Entry() : Used to retrieve both the key and value at the current position in the
dictionary.
ii) Key() : Used to retrieve the key at the current position.
ü Value() : Used to retrieve the value at the current position.
Note: The IDictionaryEnumerator interface derives from IEnumerator.
====

ArrayList:
==============================
The ArrayList is a collection class that models a dynamic array, whose size increases as
required when new objects are added to the array.
Namespace : System.Collections
Implementing Interfaces : ICollection, IList, ICloneable, IConvertible

Characteristics:
==============================
i) To store dynamic data use the arraylist class. So it is compact memory usage.
ii) The search for an item
in an arraylist is performed sequentially. So it is slow.
iii)Type of Access is indexed.

HashTable:
==============================
A HashTable is a collection of key-value pairs implemented using a hash table algorithm.
Namespace : System.Collections
Implementing Interfaces : ICollection, IDictionary

Characteristics:
==============================
i) Search is very fast.
ii) HashTables are big and fast.
iii)High Memory usage.
iv) Type of Access is using the hash of a key value.

SortedList:
==============================
A SortedList is a collection class that holds a set of key-value pairs.
Namespace : System.Collections
Implementing Interfaces : ICollection, IDictionary

Characteristics:
==============================
i) A Sorted List may not contain duplicate keys. A HashTable can have duplicate keys.
ii) Search is fast.
iii)Medium Memory usage.
iv) Type of Access is using the index and key value.

Queue and Stack:


==============================
i) Queue uses a First-In-First-Out (FIFO) Algorithm.
ii) Stack uses a Last-In-First-Out (LIFO) Algorithm.

Methods of Queue:
==============================
i) Enqueue (Add an item)
ii)Dequeue (Remove the first item)

Methods of Stack:
==============================
i) Push (Add an item)
ii)Pop (Remove the last item)
Lecture Number : 13
BY :
Reference :
1. “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-06

Contents of the Lecture


Making Decisions with If…Else Statements
How can you make choices in your code, deciding what to do next depending on the values in your
variables? You can use the If statement, which is the bread-and-butter of Visual Basic conditionals, and
which lets you evaluate your data and execute appropriate code. Here's how this statement works:
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] …]
[Else
[elsestatements]]
End If
You have to get a value from the user and respond in several different ways, but you're not looking
forward to a long and tangled series of If…Then…Else statements. What can you do?
If your program can handle multiple values of a particular variable and you don't want to stack up a lot of
If Else statements to handle them, you should consider Select Case. You use Select Case to test an
expression, determine which of several cases it matches, and execute the corresponding code. Here's the
syntax:
Select Case testexpression
[Case expressionlist-n
[statements-n]]…
[Case Else
[elsestatements]]
End Select
You use multiple Case statements in a Select statement, each specifying a different value to test against
textexpression, and the code in the Case statement that matches is executed.

LOOP
The Do loop keeps executing its enclosed statements while or until (depending on which keyword you
use, While or Until) condition is true. You can also terminate a Do loop at any time with an Exit Do
statement. The Do loop has two versions; you can either evaluate a condition at the beginning:
Do [{While | Until} condition ]
[statements]
[Exit Do]
[statements]
Loop

Using the For Loop


The For loop is probably the most popular of all Visual Basic loops. The Do loop doesn't need aloop
index, but the For loop does; a loop index counts the number of loop iterations as the loop executes.
Here's the syntax for the For loop—note that you can terminate a For loop at any time with Exit For:
For index = start To end [Step step]
[statements]
[Exit For]
[statements]
Next [index]
The index variable is originally set to start automatically when the loop begins. Each time through the
loop, index is incremented by step (step is set to a default of 1 if you don't specify a value) and when
index equals end, the loop ends.
You use the For Each…Next loop to loop over elements in an array or a Visual Basic collection. This
loop is great, because it automatically loops over all the elements in the array or collection—you don't
have to worry about getting the loop indices just right to make sure you get all elements, as you do with a
For loop. Here's the syntax of this loop:
For Each element In group
[statements]
[Exit For]
[statements]
Next [element]
Using the While Loop
While loops keep looping while the condition they test remains true, so you use a While loop if you have
a condition that will become false when you want to stop looping. Here's the While loop's syntax (note
that you used to end this loop with Wend in VB6 and before—that's changed to End While now):
While condition
[statements]
End While
The With Statement
The With statement is not a loop, properly speaking, but it can be as useful as a loop—and in fact, many
programmers actually think of it as a loop. You use the With statement to execute statements using a
particular object. Here's the syntax:
With object
[statements]
End With
Here's an example showing how to put With to work. Here, I'm use a text box, Text1, in a Windows form
program, and setting its Height, Width, and Text properties in the With statement:
With TextBox1
.Height = 1000
.Width = 3000
.Text = "Welcome to Visual Basic"
End With
What are Delegates?
In your Visual Basic.NET journey, you have definitely encountered a well used but little understood
phenomenon called a delegate. You use them everyday, but might not know it. In this article, we will take
a look at what a delegate is and how it will help you to develop better software.
A delegate can be defined as a type safe function pointer. It encapsulates the memory address of a function
in your code. Whenever you create or use an event in code, you are using a delegate. When the event is
thrown, the framework examines the delegate behind the event and then calls the function that the delegate
points to. As we will see later, delegates can be combined to form groups of functions that can be called
together.

Lecture Number : 14
BY :
Reference : “ADO.NET IN A NUTSHELL”, OREILLY, Bill Hamilton & Matthew MacDonald”. Chap-1 - 6

Contents of the Lecture

ADO .NET
Most applications need data access at one point of time making it a crucial component when working with
applications. Data access is making the application interact with a database, where all the data is stored.
Different applications have different requirements for database access. VB .NET uses ADO .NET (Active
X Data Object) as it's data access and manipulation protocol which also enables us to work with data on
the Internet. Let's take a look why ADO .NET came into picture replacing ADO.

Evolution of ADO.NET
The first data access model, DAO (data access model) was created for local databases with the built-in Jet
engine which had performance and functionality issues. Next came RDO (Remote Data Object) and ADO
(Active Data Object) which were designed for Client Server architectures but, soon ADO took over RDO.
ADO was a good architecture but as the language changes so is the technology. With ADO, all the data is
contained in a recordset object which had problems when implemented on the network and penetrating
firewalls. ADO was a
connected data access, which means that when a connection to the database is established the connection
remains open until the application is closed. Leaving the connection open for the lifetime of the
application raises concerns about database security and network traffic. Also, as databases are becoming
increasingly important and as they are serving more people, a connected data access model makes us think
about its productivity. For example, an application with connected data access may do well when
connected to two clients, the same may do poorly when connected to 10 and might be unusable when
connected to 100 or more. Also, open database connections use system resources to a maximum extent
making the system performance less effective.

Why ADO.NET?
To cope up with some of the problems mentioned above, ADO .NET came into existence. ADO .NET
addresses the above mentioned problems by maintaining a disconnected database access model which
means, when an application interacts with the database, the connection is opened to serve the request of
the application and is closed as soon as the request is completed. Likewise, if a database is Updated, the
connection is opened long enough to complete the Update operation and is closed. By keeping connections
open for only a minimum period of time, ADO .NET conserves system resources and provides maximum
security for databases and also has less impact on system performance. Also, ADO .NET when interacting
with the database uses XML and converts all the data into XML format for database related operations
making them more efficient.

The ADO.NET Data Architecture


Data Access in ADO.NET relies on two components: Dataset and Data Provider.

Dataset
The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy
of the relevant portions of the database. The Dataset is persisted in memory and the data in it can be
manipulated and updated independent of the database. When the use of this DataSet is finished, changes
can be made back to the central database for updating. The data in DataSet can be loaded from any valid
data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database.

Data Provider
The Data Provider is responsible for providing and maintaining the connection to the database. A Data
Provider is a set of related components that work together to provide data in an efficient and performance
driven manner. The .NET Framework currently comes with two Data Providers: the SQL Data Provider
which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider
which allows us to
connect to other types of databases like Access and Oracle. Each DataProvider consists of the following
component classes:
The Connection object which provides a connection to the database
The Command object which is used to execute a command
The Data Reader object which provides a forward-only, read only, connected recordset
The Data Adapter object which populates a disconnected DataSet with data and performs update

Data access with ADO.NET can be summarized as follows:


A connection object establishes the connection for the application with the database. The command object
provides direct execution of the command to the database. If the command returns more than a single
value, the command object returns a Data Reader to provide the data. Alternatively, the Data Adapter can
be used to fill the Dataset object. The database can be updated using the command object or the Data
Adapter.

Component classes that make up the Data Providers

The Connection Object


The Connection object creates the connection to the database. Microsoft Visual Studio .NET provides two
types of Connection classes: the SqlConnection object, which is designed specifically to connect to
Microsoft SQL Server 7.0 or later, and the OleDbConnection object, which can provide connections to a
wide range of database types like Microsoft Access and Oracle. The Connection object contains all of the
information required to open a connection to the database.

The Command Object


The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand.
Command objects are used to execute commands to a database across a data connection. The Command
objects can be used to
execute stored procedures on the database, SQL commands, or return complete tables directly. Command
objects provide three methods that are used to execute commands on the database:
ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or
DELETE
ExecuteScalar: Returns a single value from a database query
ExecuteReader: Returns a result set by way of a DataReader object

The DataReader Object


The DataReader object provides a forward-only, read-only, connected stream recordset from a database.
Unlike other components of the Data Provider, DataReader objects cannot be directly instantiated. Rather,
the DataReader is returned as the result of the Command object's ExecuteReader method. The
SqlCommand.ExecuteReader method returns a SqlDataReader object, and the
OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can
provide rows of data directly to application logic when you do not need to keep the data cached in
memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in
terms of system performance but requires the exclusive use of an open Connection object for the lifetime
of the DataReader.

The DataAdapter Object


The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is essentially the
middleman facilitating all communication between the database and a DataSet. The DataAdapter is used
either to fill a Data Table or Dataset with data from the database with it's Fill method. After the memory-
resident data has been manipulated, the DataAdapter can commit the changes to the database by calling
the Update method. The DataAdapter provides four properties that represent database commands:
SelectCommand
InsertCommand
DeleteCommand
Update Command
When the Update method is called, changes in the Dataset are copied back to the database and the
appropriate Insert Command, Delete Command, or Update Command is executed.

Lecture Number : 15
BY :
Reference : “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-13
“Head First Design Pattern “, O’Reilly Eric Freeman, Kathy Sierra. Chap-

Contents of the Lecture


Design patterns are recurring solutions to software design problems you find again and again in real-
world application development. Patterns are about design and interaction of objects, as well as providing
a communication platform concerning elegant, reusable solutions to commonly encountered programming
challenges.
The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are
categorized in three groups: Creational, Structural, and Behavioral. Here you will find information on
these important patterns.
To give you a head start, the C# source code is provided in 2 forms: 'structural' and 'real-world'. Structural
code uses type names as defined in the pattern definition and UML diagrams. Real-world code provides
real-world programming situations where you may use these patterns.
A third form, '.NET optimized' demonstrates design patterns that exploit built-in .NET 2.0, 3.0, and 3.5
features, such as, generics, attributes, delegates, object and collection initializers, automatic properties,
and reflection. These and much more are available in our Design Pattern Framework 3.5TM. See our
Singleton page for a .NET 3.5 Optimized code sample.
Creational Patterns
Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist

Structural Patterns
Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object

Behavioral Patterns
Chain of Resp. A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change
Lecture Number : 16
BY :
Reference :
“C# 2005”, WROX, Christian Nagel, Bill Evjen, Jay, Morgan, Karli Watson, Allen Jones. Chap-
“Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-14

Contents of the Lecture


Delegates -
Delegates are referenced to methods. So far we have used references for objects such as

Dim st as New Stack ()

In this scenario st is a reference to an object of the Stack class type. Each reference has two properties
1. The type of object (class), the reference can point to
2. The actual object referenced (or pointed) by the reference.

Delegates are similar to object references but are used to reference methods instead of objects. The type
of delegates is the type or signature of a method rather than the class. Hence a delegate has three
properties
1. The type or signature of the method the delegate can point to
2. A delegate reference which can be used to reference a method
3. The actual method referenced by the delegate
Multicast Delegate
A Multicast Delegate has a linked list of delegates, called an invocation list, consisting of one or more
elements. When
a multicast delegate is invoked, the delegates in the invocation list are called synchronously in the order in
which
they appear. If an error occurs during execution of the list then an exception is thrown
Event-
Events are defined as actions or occurrences of interest. An interested object can subscribe to an event and
be notified when it happens. For example, a button on a form can generate a click event and the form can
subscribe and get notified when the event occurs. This click event is processed through the form code.
Lecture Number : 17
BY :
Reference : “C# 2005” , WROX , Christian Nagel, Bill Evjen, Jay, Morgan, Karli Watson, Allen Jones. Chap-
8
“Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-15

Contents of the Lecture


Data Processing
String
The String Class represents character strings. The following sections describes, how to work with
VB.NET String class . The String data type comes from the System. String class. The String type
represents a string of Unicode Characters. The String class is a sealed class, so you cannot inherit
another class from the String class.
The String object is Immutable, it cannot be modified once it created, that means every time you use any
operation in the String object, you create a new String Object. So if you are in a situation in continuous
operation with String Object it is recommended to use System.Text.StringBuilder.
System.Text.StringBuilder class to modify a string without creating a new object. In the following
sections you can see the important methods in details with descriptions.
Clone
Copy
Lecture Number : 18
BY :
Reference : “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-16

Contents of the Lecture

Window Forms
Window based UI are typically cast in the following 3 style
Singled document interface (SDI) open single document such on notable or word pad or out look.
Multiple document interface (MDI) – you can open new farming the UI as your need them you
obtained to close form before opening new ones (Contain numbers forms)
Employer style interface – Microsoft out look, window explore
System . Window .form Names space – This provides the base functionality for all controls that
is display on a form.
The classes in this namespace can be grouped as follows:-
Control
User Control
Forms
Controls
Component
Common Dialog Box
Introduction to threadiry :- System Threading

Introduction Application Domain – Application domin is construct in the CLR that is the Unit of
isolation open
an application
Application can be independently stopped
An application can not direct access code or resources in another application.
A fault in application can't effect other application.
Lecture Number : 19
BY :
Reference : “Complete ReferencrVB.NET 2.0”, Tata McGraw Hill, Jeffery R. Shapiro. Chap-16

Contents of the Lecture

1. MDI Application :

2. Component & Control :


Collection User Input
Lecture Number : 20
BY :
Reference : “Complete ReferencrVB.NET 2.0”, Tata McGraw Hill, Jeffery R. Shapiro. Chap-16

Contents of the Lecture


1. Presentation & information Controls
Some controls & component are designed to present information to user . These include the control
listed.
2. Introduction of
ASP NET :- This is useful for web development application . It is advancement of ASP.
3. Different between ASP & ASP NET
4. ASP NET Server Control
HTML Server
Web Server
Custom & Uses
5. Difference between HTML Server & web server Control.

Lecture Number : 21
BY :
Reference :
1. “Professional ASP.NET 2.0” , WROX , Bill Evjen, Scott, Devin Reader, Farhan, s.srinivas
Chap-14
2. “Programming ASP.NET” , OREILLY , Jesse Liberty & Dan Hurwitz. Chap-6

Contents of the Lecture


State Management
Client Side Server Side
Query String Session
Cooking Application
Hidden field
View State
A new instance of the Web page class is created each time the page is posted to the server. In traditional
Web programming, this would typically mean that all information associated with the page and the
controls on the page would be lost with each round trip. For example, if a user enters information into a
text box, that information would be lost in the round trip from the browser or client device to the server.
To overcome this
inherent limitation of traditional Web programming, ASP.NET includes several options that help you
preserve data on both a per-page basis and an application-wide basis. These features are as follows:
· View state

· Control state

· Hidden fields

· Cookies

· Query strings

· Application state

· Session state

· Profile Properties

Client-Based State Management Options


The following sections describe options for state management that involve storing information either in
the page or on the client computer. For these options, no information is maintained on the server between
round trips.
View State
The View State property provides a dictionary object for retaining values between multiple requests for
the same page. This is the default method that the page uses to preserve page and control property values
between round trips.
When the page is processed, the current state of the page and controls is hashed into a string and saved in
the page as a hidden field, or multiple hidden fields if the amount of data stored in the View State property
exceeds the specified value in the MaxPageStateFieldLength property. When the page is posted back to
the server, the page parses the view-state string at page initialization and restores property information in
the page.
You can store values in view state as well. The following example shows how to store a value in the view
state.
[Visual Basic]
ViewState("color") = "red"

[C#]
ViewState["color"] = "red";

Hidden Fields
ASP.NET allows you to store information in a HiddenField control, which renders as a standard HTML
hidden field. A hidden field does not render visibly in the browser, but you can set its properties just as
you can with a standard control. When a page is submitted to the server, the content of a hidden field is
sent in the HTTP form
collection along with the values of other controls. A hidden field acts as a repository for any page-specific
information that you want to store directly in the page.
A HiddenField control stores a single variable in its Value property and must be explicitly added to the
page. The following example shows a HiddenField control with an initial value.
<asp:hiddenfield id="ExampleHiddenField"
value="Example Value"
runat="server"/>
In order for hidden-field values to be available during page processing, you must submit the page using an
HTTP POST command. If you use hidden fields and a page is processed in response to a link or an HTTP
GET command, the hidden fields will not be available.
Cookies
A cookie is a small amount of data that is stored either in a text file on the client file system or in-memory
in the client browser session. It contains site-specific information that the server sends to the client along
with page output. Cookies can be temporary (with specific expiration times and dates) or persistent.
You can use cookies to store information about a particular client, session, or application. The cookies are
saved on the client device, and when the browser requests a page, the client sends the information in the
cookie along with the request information. The server can read the cookie and extract its value. A typical
use is to store a token (perhaps encrypted) indicating that the user has already been authenticated in your
application.
The following example shows how to write a cookie.
Visual Basic

Response.Cookies("destination").Value = "CA"
Response.Cookies("destination").Expires = DateTime.Now.AddDays(1)
C#

Response.Cookies["destination"].Value = "CA";
Response.Cookies["destination"].Expires = DateTime.Now.AddDays(1);
For more information about using cookies, see Cookies, ASP.NET Cookies Overview, and ASP.NET
State Management Recommendations.
Query Strings
A query string is information that is appended to the end of a page URL. A typical query string might look
like the following example:
http://www.contoso.com/listwidgets.aspx?category=basic&price=100

In the URL path above, the query string starts with a question mark (?) and includes two attribute/value
pairs, one called "category" and the other called "price."
Query strings provide a simple but limited way to maintain state information. For example, they are an
easy way to pass information from one page to another, such as passing a product number from one page
to another page where it
will be processed. However, some browsers and client devices impose a 2083-character limit on the length
of the URL.
In order for query string values to be available during page processing, you must submit the page using an
HTTP GET command. That is, you cannot take advantage of a query string if a page is processed in
response to an HTTP POST command. For usage recommendations.
Server-Based State Management Options
ASP.NET offers you a variety of ways to maintain state information on the server, rather than persisting
information on the client. With server-based state management, you can decrease the amount of
information sent to the client in order to preserve state, however it can use costly resources on the server.
The following sections describe three server-based state management features: application state, session
state, and profile properties.
Application State
ASP.NET allows you to save values using application state — which is an instance of the
HttpApplicationState class — for each active Web application. Application state is a global storage
mechanism that is accessible from all pages in the Web application. Thus, application state is useful for
storing information that needs to be maintained between server round trips and between requests for
pages. For more information.
Application state is stored in a key/value dictionary that is created during each request to a specific URL.
You can add your application-specific information to this structure to store it between page requests.
Once you add your application-specific information to application state, the server manages it. For usage
recommendations.
The following example shows how to assign a value in application state.
[Visual Basic]

Application("WelcomeMessage") = "Welcome to the Contoso site."


[C#]
Application["WelcomeMessage"] = "Welcome to the Contoso site.";
Session State
ASP.NET allows you to save values by using session state — which is an instance of the HttpSessionState
class — for each active Web-application session. For an overview, see ASP.NET Session State Overview.
Session state is similar to application state, except that it is scoped to the current browser session. If
different users are using your application, each user session will have a different session state. In addition,
if a user leaves your application and then returns later, the second user session will have a different session
state from the first.
Session state is structured as a key/value dictionary for storing session-specific information that needs to
be maintained between server round trips and between requests for pages. For more information, see
ASP.NET Session State Overview.
You can use session state to accomplish the following tasks:
· Uniquely
identify browser or client-device requests and map them to an individual session instance on the
server.

· Store session-specific data on the server for use across multiple browser or client-device requests
within the same session.

· Raise appropriate session management events. In addition, you can write application code
leveraging these events.

Once you add your application-specific information to session state, the server manages this object.
Depending on which options you specify, session information can be stored in cookies, on an out-of-
process server, or on a computer running Microsoft SQL Server. For usage recommendations.
The following example shows how to save a value in session state.
Visual Basic

Session("FirstName") = FirstNameTextBox.Text
Session("LastName") = LastNameTextBox.Text

C#

Session["FirstName"] = FirstNameTextBox.Text;
Session["LastName"] = LastNameTextBox.Text;

Profile Properties
ASP.NET provides a feature called profile properties, which allows you to store user-specific data. This
feature is similar to session state, except that the profile data is not lost when a user's session expires. The
profile-properties feature uses an ASP.NET profile, which is stored in a persistent format and associated
with an individual user. The ASP.NET profile allows you to easily manage user information without
requiring you to create and maintain your own database. In addition, the profile makes the user
information available using a strongly typed API that you can access from anywhere in your application.
You can store objects of any type in the profile. The ASP.NET profile feature provides a generic storage
system that allows you to define and maintain almost any kind of data while still making the data available
in a type-safe manner.
To use profile properties, you must configure a profile provider. ASP.NET includes a SqlProfileProvider
class that allows you to store profile data in a SQL database, but you can also create your own profile
provider class that stores profile data in a custom format and to a custom storage mechanism such as an
XML file, or even to a web service.
Because data that is placed in profile properties is not stored in application memory, it is preserved
through Internet Information Services (IIS) restarts and worker-process restarts without losing data.
Additionally, profile properties can be persisted across multiple processes such as in a Web farm or a Web
garden. For more information, see ASP.NET Profile Properties Overview.
The following example shows how to save a profile value.
Visual Basic
Profile.PostalCode = txtPostalCode.Text
C#
Profile.PostalCode = txtPostalCode.Text;
You must define the PostalCode property in the Web.config file by using the following markup:
Webservice
The term Web services describes a standardized way of integrating Web-based applications using the
XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag
the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI
is used for listing what services are available. Used primarily as a means for businesses to communicate
with each other and with clients, Web services allow organizations to communicate data without intimate
knowledge of each other's IT systems behind the firewall.

Remoting
NET Remoting is an enabler for application communication. It is a generic system for different
applications to use to communicate with one another. .NET objects are exposed to remote processes, thus
allowing interprocess communication. The applications can be located on the same computer, different
computers on the same network, or even computers across separate networks.
Remoting: This is good technology for peer to peer communication Remoting you need the client to be
NET. Compliant.
Webservice: Web Service is business logic that provide function theory net (Internet).

Lecture Number : 23
BY :
Reference :

Contents of the Lecture


Lecture Number : 24
BY :
Reference :

Contents of the Lecture


MCA- 504
.NET Technology
(Jul-Dec 2010)
Tutorial-1
Q1. What are major benefits of .net?
Ans-
Managed code is more robust. The .Net platform not only runs this new type of
code but oversees its execution allowing software errors to be caught and halted
before serious problems can occur. "Memory leaks", "memory corruption", and
"blue screen of death" problems that freeze our old Windows systems in their
tracks are prevented by .Net or curtailed before damage is done.

Side-by-side versions. .Net software minds its own business. It stays together in one place rather than
smearing itself all around our systems. And in doing so, it sidesteps the old Component Object Model
(COM) -based mechanisms that allowed software packages to collide with and harm one another. In
fact, .Net allows two versions of a managed code application to run side by side on the same computer
without any interaction or conflict. .Net thus eliminates the need to remove an old version of a
software product just to install and try out a new version.

Better security. .Net security model is a promising new weapon in halting rogue software and security
breaches. You've heard the old adage that you're either part of the solution or part of the problem.
Managed code is part of the solution.

Better connectivity. The new .Net software development tools and the standards based nature of
managed code make it easier to develop systems that employ state-of the-art connectivity techniques
such as XML Web Services. Our future will clearly be filled with a kaleidoscope of constantly
collaborating systems, large and small, networked together, exchanging information and performing
services for each other and for mankind. Building this high level of connectivity and requisite
robustness demands new components, tools, and a standards-oriented approach. Getting there with old
components and tools and without standards is an impossible challenge. .Net comes with a blueprint
and toolset for the next generation of software for the new "connected world".

Faster software, faster development, easier deployment. .Net is a completely new software
technology, created from scratch, both to leverage groundbreaking technologies such as XML.
Managed code is lean, speedy, and lightweight. These traits enable new innovation in application
development and deployment. And, .Net includes a huge box of prefabricated industrial-strength
components ready to use by software developers, allowing developers to save time while creating
more robust and powerful applications.

Lower cost of ownership. Each of the managed code advantages listed above promise to contribute to
lower IT costs due to easier software development, easier and more trouble-free deployment,
installation, maintenance, and security. The advantages of managed code are clear and recognition of
this fact is gradually growing in the public consciousness and corporate boardrooms. Just as there
came a day when the MS-DOS-based software market was pronounced dead, so will come the day
when software purchasers will only settle for managed code. .Net is a new and better kind of software
and a new set of
tools to build it. And yes, .Net makes it easier to build and deploy the XML Web Services that
everyone is talking about.

Q2. What are difference between VB and VB.NET?


Ans-

There are quite a few differences in VB6 and VB.NET. We will highlight some of these here
in points:

· The greatest change in VB6 and VB.NET is of runtime environment. VB6 used the VB-
Runtime while VB.NET uses the .Net Common Language Runtime (.Net CLR). The CLR is
much better designed and implemented than VB-Runtime. The CLR uses better code
translation through Just in Time compiler while VB-Runtime interprets the code. The CLR
Garbage Collector is also more efficient than VB6 one as it may detect cyclic references too.
· VB6 was interpreter based language while VB.NET is a compiled language
· VB6 was not a type-safe language while VB.NET is a type safe language. There is no variant
type in VB.NET and no magical type conversions happen in VB.NET
· VB6 used ‘On Error Goto’ syntax to handle exceptions at runtime. VB.NET uses the
Try…Catch…Finally syntax to handle exceptions at runtime.
· A lot of code (like user interface code) in VB6 was hidden from developer. In VB.NET no
code is hidden from developer and you can access and control each part of your application
· VB6 does not allow developing the multithreaded applications. In VB.NET you can create
multithreaded applications.
· VB6 was only considered good for desktop windows application. In VB.NET you can also
develop web applications, distributed applications, create .NET windows and web controls and
components, write windows and web services.
· In VB.NET, you can also use reflections to read the meta-data of types and using reflection
emit you can also generate code to define and invoke types at runtime.
· VB.NET uses .NET framework class library along with specialized VB library (System. Visual
Basic) as a standard library. As a result, the standard library for VB.NET is much enhanced
and useful compared to VB6 standard library
· VB.NET is platform independent because of .Net framework. Programs written in VB.NET
can run on any platform where .Net framework is present. The platform include both hardware
and software (operating system) platforms.
· VB.NET also supports language interoperability with various .NET compliant languages. This
means that you can use and enhance the code written in other .NET compliant languages.
Similarly the
code written in VB.NET can also be used and enhanced by other .NET compliant languages.
Although VB6 also provided this functionality through COM but it was limited and difficult to
use and manage. VB.Net makes it easier because of the presence of Intermediate Language
(IL) and Common Language Specification (CLS) of the .NET architecture.
· VB6 uses COM (Component Object Model) as component architecture. VB.NET uses
assemblies as its component architecture. The Assemblies architecture has removed a lot of
problems with COM including DLL-Hell and versioning problem.
· Components created in VB6 (COM) need to make and update registry entries. VB.NET does
not require any registry entry making the deployment easier

· VB6 used ASP to build web applications. VB.NET uses ASP.NET to build web applications.
· VB6 used ADODB and record-sets to implement data access applications. VB.NET uses
ADO.NET and datasets to build data access applications. The ADO.NET also supports the
disconnected data access.

Q3. What is DLL HELL &Versioning problem?


Ans-
DLL HELL- Prior .NET very tuff task to develop application that time there are many issue like
There is no control entity that is responsible for all of the DLL file installed on to a system.
Information about COM DLL is held in the registry. It can be easily overwritten by another
application. There is no system enforcement of versioning rule between components. It is left to the
best practices the coding which says that once an interface is published it can never be changed but
there is nothing in operating system that explicitly prevents this from happening.
Versioning Problem-The other problem is no common way for an application to say that it need
version 1.2.1.1234 of a particular component. It is left up to the developer to check the version of a
DLL before calling into it. When you want to update your application on web server. Prior to .NET, to
do this you had to stop the entire website, copy a file across and then restart the web site. Even worse,
sometime you had to reboot a machine because COM & IIS just seem to get confused and do not
release file correctly. This is a pain during the development of an application, and is unacceptable for
production sites that must always be running. This problem is caused by the way com manage file such
as DLL’s. Once they are loaded you cannot overwrite them. Unless they are unloaded during an idle
period of course may never happen on busy web server. .NET component do not have to be locked like
this. They can be overwritten at any time.

Q4. What is CLR and explain its function.


Ans-
CLR –
· Manage & unmanaged code
· MSIL (Compiler/Interpreter)
· MSIL – IL-JIT (Twice compilation)
· Assembly – Physically group of logical unit
· CTS, CLS, GC, GAC. etc.
· Name space – Logically groups classes.
· Side by side executions
MCA- 504
.NET Technology
(Jul-Dec 2010)
Tutorial-2

Q1. What is boxing and unboxing?

Ans- Boxing is the process of converting a value type to the type object or to any interface type
implemented by this value type. When the CLR boxes a value type, it wraps the value inside a
System.Object and stores it on the managed heap. Unboxing extracts the value type from the object. In
the following example, the integer variable i is boxed and assigned to object o.

Class Test
Shared Sub Main()
Dim i As Integer = 1
Dim o As Object = i ' boxing
Dim j As Integer = CInt(o) ' unboxing
End Sub 'Main
End Class 'Test

int i =123;
Object o=(object)I; //Boxing
The object o can then be unboxed and assigned to integer variable i:
C#
O=123;
i=(int)o; // unboxing

Boxing
Boxing is used to store
value types in the garbage-collected heap. Boxing is an implicit conversion of a value type to the type
object or to any interface type implemented by this value type. Boxing a value type allocates an object
instance on the heap and copies the value into the new object.
Consider the following declaration of a value-type variable:
int i = 123;
The following statement implicitly applies the boxing operation on the variable i:
object o = i; // Implicit boxing
The result of this statement is creating an object reference o, on the stack, that references a value of the
type int, on the heap. This value is a copy of the value-type value assigned to the variable i. The difference
between the two variables, i and o, is illustrated in the following figure.
Boxing Conversion

It also possible to perform the boxing explicitly as in the following example, but explicit boxing is never
required:
int i = 123;
object o = (object)i; // explicit boxing
This example converts an integer variable i to an object o by using boxing. Then, the value stored in the
variable i is changed from 123 to 456. The example shows that the original value type and the boxed
object use separate memory locations, and therefore can store different values.
class TestBoxing
{
static void Main()
{
int i = 123;
object o = i; // Implicit boxing

i = 456; // Change the contents of i

System.Console.WriteLine("The value-type value = {0}", i);


System.Console.WriteLine("The object-type value = {0}", o);
}
}
/* Output:
The value-type value = 456
The object-type value = 123
*/
The following example
demonstrates a case of invalid unboxing and the resulting InvalidCastException. Using try and catch, an
error message is displayed when the error occurs.
class TestUnboxing
{
static void Main()
{
int i = 123;
object o = i; // implicit boxing

try
{
int j = (short)o; // attempt to unbox

System.Console.WriteLine("Unboxing OK.");
}
catch (System.InvalidCastException e)
{
System.Console.WriteLine("{0} Error: Incorrect unboxing.", e.Message);
}
}
}
This program outputs:
Specified cast is not valid. Error: Incorrect unboxing.

If you change the statement:


int j = (short) o;
to:
int j = (int) o;
the conversion will be performed, and you will get the output:
Unboxing OK.
Unboxing
Unboxing is an explicit conversion from the type object to a value type or from an interface type to a
value type that implements the interface. An unboxing operation consists of:
· Checking the object instance to make sure that it is a boxed value of the given value type.

· Copying the value from the instance into the value-type variable.

The following statements demonstrate both boxing and unboxing operations:


int i = 123; // a value type
object o = i; // boxing
int j = (int)o; // unboxing
The following figure
demonstrates the result of the previous statements.
Unboxing Conversion

For the unboxing of value types to succeed at run time, the item being unboxed must be a reference to an
object that was previously created by boxing an instance of that value type. Attempting to unbox null
causes a NullReferenceException. Attempting to unbox a reference to an incompatible value type causes
an InvalidCastException.

Q2. Explain class library of framework.


Ans-
The .NET Framework includes classes, interfaces, and value types that expedite and optimize the
development process and provide access to system functionality. To facilitate interoperability between
languages, most .NET Framework types are CLS-compliant and can therefore be used from any
programming language whose compiler conforms to the common language specification (CLS).
The .NET Framework types are the foundation on which .NET applications, components, and controls are
built. The .NET Framework includes types that perform the following functions:

· Represent base data types and exceptions.

· Encapsulate data structures.

· Perform I/O.

· Access information about loaded types.

· Invoke .NET Framework security checks.

· Provide data access, rich client-side GUI, and server-controlled, client-side GUI.

The .NET Framework provides a rich set of interfaces, as well as abstract and concrete (non-abstract)
classes. You can use the concrete classes as is or, in many cases, derive your own classes from them. To
use the functionality of an interface, you can either create a class that implements the interface or derive a
class from one of the .NET Framework classes that implements the interface.
Q3. What is difference
between value type and reference type?
Ans-
Value Type
Value type store it value directly stored in stack. Value type may not contain null value. They just
fall off the stack when they fall out of scope. GC not removes.

Reference Type
Reference type store a reference to the value stored in managed heap. Reference type picked up by
GC when their reference goes null (remove by GC). Contain null value.

Q4. Explain different type of access modifier.


Ans-
The access modifiers in .NET are
public
private
protected
internal
protected internal
Both C# and VB.NET includes optional keywords that correspond to the five access levels. The following
list provides an overview of these keywords as used in C#:

public: No access restrictions.


protected: Access limited to containing/derived classes.
internal: Access limited to containing type.
protected internal: Access limited to the current project.
private: Access limited to containing/derived classes and the current project.

The corresponding VB.NET list follows:

Public: No access restrictions.


Protected: Access limited to containing/derived classes.
Private: Access limited to containing type.
Friend: Access limited to the current project.
Protected Friend: Access limited to containing/derived classes and the current project.

MCA- 504
.NET Technology
(Jul-Dec 2010)
Tutorial-3

Q1. What is polymorphism?


Ans-
Polymorphism is one of the crucial features of OOP. It means”one name, multiple forms". It is
also called as Overloading which means the use of same thing for different purposes. Using
Polymorphism we can create as many functions we want with one function name but with different
argument list. The function performs different operations based on the argument list in the function
call. The exact
function to be invoked will be determined by checking the type and number of arguments in the
function.
The following code demonstrates the implementation of Polymorphism.
Module Module1

Sub Main()
Dim two As New One()
WriteLine(two.add(10))
'calls the function with one argument
WriteLine(two.add(10, 20))
'calls the function with two arguments
WriteLine(two.add(10, 20, 30))
'calls the function with three arguments
Read()
End Sub

End Module

Public Class One


Public i, j, k As Integer

Public Function add(ByVal i As Integer) As Integer


'function with one argument
Return i
End Function

Public Function add(ByVal i As Integer, ByVal j As Integer) As Integer


'function with two arguments
Return i + j
End Function

Public Function add(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer) As Integer


'function with three arguments
Return i + j + k
End Function

End Class

Output of the above code is shown in the image below.


10
30
60
Q2. Explain
array and array list.
Ans-
Arrays are programming constructs that store data and allow us to access them by numeric index
or subscript. Arrays helps us create shorter and simpler code in many situations. Arrays in Visual Basic
.NET inherit from the Array class in the System namespace. All arrays in VB are zero based, meaning, the
index of the first element is zero and they are numbered sequentially. You must specify the number of
array elements by indicating the upper bound of the array. The upper bound is the numder that specifies
the index of the last element of the array. Arrays are declared using Dim, ReDim, Static, Private, Public
and Protected keywords. An array can have one dimension (liinear arrays) or more than one
(multidimensional arrays). The dimensionality of an array refers to the number of subscripts used to
identify an individual element. In Visual Basic we can specify up to 32 dimensions. Arrays do not have
fixed size in Visual Basic.
The following code demonstrates arrays.
Imports System.Console
Module Module1

Sub Main()
Dim sport(5) As String
'declaring an array
sport(0) = "Soccer"
sport(1) = "Cricket"
sport(2) = "Rugby"
sport(3) = "Aussie Rules"
sport(4) = "BasketBall"
sport(5) = "Hockey"
'storing values in the array
WriteLine("Name of the Sport in the third location" & " " & sport(2))
'displaying value from array
End Sub

End Module

Understanding the Code


The above code declared a sport array of type string like this: Dim sport(5) as String. This sport array has
6 elements starting from sport(0) to sport(5). The first element of an array is always referred by zero
index. The image below displays output from above code.

O/P- Name of the Sport in third location Rugby

You can also declare an array without specifying the number of elements on one line, you must provide
values for each element when initializing the array. The following lines demonstrate that:

Dim Test() as Integer


'declaring a Test array
Test=New Integer(){1,3,5,7,9,}
Reinitializing Arrays
We can change the size of an array after creating them. The ReDim statement assigns a completely new
array object to the specified array variable. You use ReDim statement to change the number of elements in
an array. The following lines of code demonstrate that. This code reinitializes the Test array declared
above.
Dim Test(10) as Integer
ReDim Test(25) as Integer
'Reinitializing the array
When using the Redim statement all the data contained in the array is lost. If you want to preserve existing
data when reinitializing an array then you should use the Preserve keyword which looks like this:
Dim Test() as Integer={1,3,5}
'declares an array an initializes it with three members
ReDim Preserve Test(25)
'resizes the array and retains the the data in elements 0 to 2

Multidimensional Arrays
All arrays which were mentioned above are one dimensional or linear arrays. There are two kinds of
multidimensional arrays supported by the .NET framework: Rectangular arrays and Jagged arrays.

Rectangular arrays
Rectangular arrays are arrays in which each member of each dimension is extended in each other
dimension by the same length. We declare a rectangular array by specifying additional dimensions at
declaration. The following lines of code demonstrate the declaration of a multidimensional array.
Dim rectArray(4, 2) As Integer
'declares an array of 5 by 3 members which is a 15 member array
Dim rectArray(,) As Integer = {{1, 2, 3}, {12, 13, 14}, {11, 10, 9}}
'setting initial values
Jagged Arrays
Another type of multidimensional array, Jagged Array, is an array of arrays in which the length of each
array can differ. Example where this array can be used is to create a table in which the number of columns
differ in each row. Say, if row1 has 3 columns, row2 has 3 columns then row3 can have 4 columns, row4
can have 5 columns and so on. The following code demonstrates jagged arrays.
Dim colors(2)() as String
'declaring an array of 3 arrays
colors(0)=New String(){"Red","blue","Green"}
initializing the first array to 3 members and setting values
colors(1)=New String(){"Yellow","Purple","Green","Violet"}
initializing the second array to 4 members and setting values
colors(2)=New String(){"Red","Black","White","Grey","Aqua"}
initializing the third array to 5 members and setting values

Differences-
1. ArrayLis
t is a collection datatype which takes value/key pair. You need to use .Add property to add
values to the arraylist collection. You can access the arraylist using keys.
2. Array is a datatype which can be accessed using indexes.

Q3. Explain OOP’s concept regarding VB.NET.


Ans-
Abstraction
Encapsulation
Inheritance
Polymorphism

Q4. What are differences between string and string builder?


Ans-
String objects are immutable, which means that once they are created they cannot be changed. When
we use one of the methods of the String class, we create a new string object.

For example: (String strSen = “hello”; //Creates a new object) when we concatenate any other words
along with strSen variable it does not actually modify the strSen variable, instead it creates a whole
new string.
For example: strSen = strSen + “Hello”;

StringBuilder are mutable class, which means when concatenate any text to the variable it allows us
to modify the original value without creating a new object.
You can use StringBuilder's Append () method to use concatenation.
MCA- 504
.NET Technology
(Jul-Dec 2010)

Tutorial-4
Q1. What is Design Pattern? And explain singleton design pattern.
Ans-
Complete Reference Visual Basic. NET Pno-553

Q2. What are differences between ADO and ADO.NET?


Ans-
ADO works with connected data. This means that when you access data, such as viewing and
updating data, it is real-time, with a connection being used all the time. This is barring, of course, you
programming special routines to pull all your data into temporary tables.

ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy of the
data using XML. ADO.NET only holds the connection open long enough to either pull down the data
or to make any requested updates. This makes ADO.NET efficient to use for Web applications. It's
also decent for desktop applications.

· ADO has one main object that is used to reference data, called the Recordset object. This object
basically gives you a single table view of your data, although you can join tables to create a new set of
records. With ADO.NET, you have various objects that allow you to access data in various ways. The
DataSet object will actually allow you to store the relational model of your database. This allows you
to pull up customers and their orders, accessing/updating the data in each related table individually.

· ADO allows you to create client-side cursors only, whereas ADO.NET gives you the choice of either
using client-side or server-side cursors. In ADO.NET, classes actually handle the work of cursors. This
allows the developer to decide which is best. For Internet development, this is crucial in creating
efficient applications.

· Whereas ADO allows you to persist records in XML format, ADO.NET allows you to manipulate
your data using XML as the primary means. This is nice when you are working with other business
applications and also helps when you are working with firewalls because data is passed as HTML and
XML.

Q3. What are differences between Data reader and Data Set?
Ans-
Dataset
Data set can be said as a temporary data base which works on disconnected architecture which
stores schema and data in application memory area..It fetches all data at a time.DML is
entertained here
Data Reader
Datareader is
like a forward only recordset. It fetches one row at a time.DataReader is readonly so we cannot
do any transaction on them. DataReader will be the best choice
where we need to show the data to the user which requires no transaction ie reports. Due to
DataReader is forward only we cannot fetch the data randomly. .NET Dataproviders
optimizes the datareaders to handle the huge amount of data.

MCA- 504
.NET Technology
(Jul-Dec 2010)
Tutorial-5

Q1. Explain how many object in .NET.


Ans-
There are 6 premade objects in ASP.net
a) Server
b) Session
c) Application
d) ObjectContext
e) Response
f) Request

Q2. What are differences between Response. Redirect and Server. Transfer?
Ans-
Server.Transfer transfers page processing from one page directly to the next page without making
a round-trip back to the client's browser. This provides a faster response with a little less overhead on the
server. Server.Transfer does not update the clients url history list or current url.

Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back
to the client where the client's browser is redirected to the new page. The user's browser history list is
updated to reflect the new address.
Q3. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading
process.
Ans-
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other
things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter
aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

Q4. How many validation control in .net and What data types do the Range Validator control
support?
Ans-
With ASP.NET, there are six(6) controls included. They are:
· The RequiredFieldValidation Control
· The CompareValidator Control
· The
RangeValidator Control
· The RegularExpressionValidator Control
· The CustomValidator Control
Range Validator control support Integer,Date,String,Double,Currency data type

Objective Question Answer


MCA-504
1. Which of the following information is contained in the assembly manifest?

1. Files
2. Identity
3. Security Permissions
4. All of the above
2. Any project that compiles to an EXE or DLL files produces an assembly in .NET.

1. True
2. False
3. Which of the following is the best to retrieve Read-Only, Forward-only stream of data from database?

1. Data Set
2. Typed Data Set
3. DataReader
3. Which of the following is the best to retrieve Read-Only, Forward-only stream of data from database?

1. Data Set
2. Typed Data Set
3. DataReader
4. Which of the following is the best to retrieve Read-Only, Forward-only stream of data from database?

1. Data Set
2. Typed Data Set
3. DataReader
5. Which of the following is not a method of Debug class?

1. Assert( )
2. Flush( )
3. Open( )

6. ________________ is used to step through each line of code as it executes, including calls to other
function.

1. Step Out
2. Step Over
3. Step Into
4. Run to Cursor
5. Set Next Statement
7. COM Exception class is a part of _____________

1. System.Runtime.Interopservices
2. System.XML
3. System. Data
8. The methods declared with the following modifiers are not accessible out side the current VB.NET
project

1. Public
2. Protected
3. Friend

9. Default properties are always a parameterized property.

1. True
2. False
10. How do you limit implicit type conversion in VB.NET?

1. Option Strict On
2. Option Strict=1
3. Options Strict True
4. Option Strict off
11. Is the Class type in VB.NET a value type?

1. Yes
2. No
12. Choose the correct statement about a delegate in VB.NET

1. A delegate is a strongly type function pointer


2. It is a type-safe function pointer
3. Delegates are used to create associations between events and event handlers in VB.NET
4. All of the above statements are correct for a delegate
13. Which of the following is not the member of System.Collections?

1. BitArray
2. Enum
3. Queue
4. Stack
14. Which of the following control can contain other controls?

1. GroupBox
2. TabPage
3. Panel
4. All of the above
15. Which of the following object is used by the DataAdapter to retrieve the data from database?

1. Command
2. Connection
3. DataReader
16. Which of the following control doesn't receive the focus and doesn't have a TabIndex property?

1. PictureBox
2. LablControl
3. ListBox
4. TabControl control
17. Which of the following is not true for Shared members?

1. Shared members belong to the type but not to any instance of a type
2. They can be accessed without creating an instance of the type.
3. They can be accessed using the type name
4. They are accessed using instance name

18. If no access modifier is specified for a class, it is considered ____________

1. Public
2. Private
3. Friend
4. Protected
19. System.Collections represents container type for

1. Arraylist
2. Sortedlist
3. Queue
4. Stack
5. All of the above
20. Which of the following namespace provides support for obtaining information and dynamic creation
of types at runtime?

1. System.IO
2. System.ComponentModel
3. System.Reflection
4. System.Data
21. The smallest unit to which one can associate a version number in .NET is

1. CLR
2. Assembly
3. Namespace
4. None of the Above
22. Lower bound value of array in VB.NET

1. -1
2. 0
3. 2
4. 3
23. Which of the
following is not correct about the value types and reference types in VB.NET?

1. Dim statement is used to create a variable that represents a value type


2. Data associated with a value type is allocated on the stack
3. Reference types must be instantiated after declaration
4. Data associated with a reference type is allocated on the stack
24. Which NameSpace is used to access the metadata in an Assembly?

1. System.XML
2. System.Assembler
3. System.Reflection
4. System.IO

24. Which NameSpace is used to access the metadata in an Assembly?

1. System.XML
2. System.Assembler
3. System.Reflection
4. System.IO

26. In VB.NET, the finalizer must use the Overrides keyword

1. True
2. False
27. Which one of the following collections receives output from Trace and Debug classes?

1. Trace
2. Debug
3. Listeners
4. None
28. Using ___________ we can determine if a variable is initialized in VB.NET

1. IsDdNull( )
2. IsEmpty( )
3. ISNull( )
29. ______________ can be accessed from all types within the assembly, but not from outside the
assembly.

1. Public
2. Private
3. Friend
4. Protected
5. Protected Friend
30. How to dereference an object in VB.NET?

1. By setting the object to Null


2. By setting the object to Nothing
3. With Close keyword
4. None of the
above
31. Smart Phone applications and other such devices can be written using:

1. .NET Compact Framework


2. .NET Small Framework
3. .NET Smartclient Framwork
32. Which class is used to run the EXE application file in VB.NET?

1. Process
2. Application
3. Exe
4. Execute
33. Which of the following namespaces is used to access "computer name" and its IP address in VB.NET?

1. System.NET.DNS
2. System.Diagnostics.Process
3. System.Data.Common
4. None of the Above
34. If you know want to migrate your Visual Basic 6 application to VB.NET, what is the first thing
you should do ?
Schedule meetings with end users to see what features they want to add to the app.
Open the Visual Basic Upgrade Wizard, get a cup of coffee and watch it run.
Assess the VB 6 application; find out what controls it uses, what projects are in there and so on.
Cancel all social plans for the next couple months and start rewriting the app in .NET.

1. Some bits of a Visual Basic 6 application, like most APIs, can be easily migrated to VB.NET;
other parts are not so straightforward. Which of the following will NOT have to be re-architected
during a VB 6-to-VB.NET migration ?
DHTML pages
ADO to ADO via Interop
ActiveX documents
OLE controls
2. The Visual Basic Upgrade Wizard will convert all the code in your VB 6 application to VB.NET
code for you.
False
True
Not always
Can't say
3. This programming language model is used sparingly in VB 6 but is one of the cornerstones of
VB.NET. Knowing the ins and outs of it will make an application migration project easier and also
prepare you for additional work in VB.NET. What is the model ?
Modular programming
Aspect-oriented programming
Reflective programming
Object-oriented
programming
4. What two controls are needed when creating a toolbar ?
Only Toolbar control
ImageList and Toolbar control
Both 1 and 2
All the above
5. Can a toolbar display text instead of pictures in the buttons ?
No, a toolbar can only display images
No, a toolbar can only display text
Yes, a toolbar can display text, images, or both.
None of these
6. The vbc.exe compiler generates:
IL Code
Native code
Byte Code
None of these
7. which program will you use to assemble a program written in IL:
ildasm
clr
ilasm
All the above

8. A ‘for’ loop will run faster in VB.NET or C# ?


VB.NET
C#
Both of them will run equally fast.
None of these
9. What’s the difference between a class field property ?
A field always has Get and Set Methods
A property always has Get and Set Methods
Both 1 and 2
None of the above
10. Classes from which namespace will have to be used to read or write to a file ?
System.FileObjects
System.FileSystem
System.IO
System.Input/Output
11. The metadata
stored in the assembly is called :
AssemblyInfo
manifest
AssemblyData
None of these
12. My.Application.Log.WriteEntry , by default , writes to the file:
Applog.Log
Application.Log
assemblyname.log
None of these
13. To determine the folder in which your application is placed you can use:
My.Computer.CurrentFolder
My.Application.CurrentFolder
My.System.CurrentFolder
All the above
14. Select the keyword used to refer the name space in our code in VB.Net
Using
Package
Imports
None of the above
15. How does VB.NET instantiates the .NET object
Using NEW keyword
Using CREATEOBJECT keyword
Using GETOBJECT keyword
Both A & B

16. How do you Dereference an Object in VB.NET ?


By setting the object to Null
With Close keyword
By setting the object to Nothing
None of the above
17. How do you Create Constructors in VB.NET ?
Create a method and name it with the same name as class name
Create a method and which is named as New
Create a method and which is named as Initialize
None of the above
18. How do you enable Strict Type Checking in VB.NET
With OPTION
STRICT ON keyword
With OPTION EXPICIT Keyword
With OPTION STRICT OFF keyword
All the above
19. Can you create Windows Services using VB.Net
Yes
No
Not always
None of these

Question Bank

VISUAL BASIC.NET MCA-504 5th Semester

Section-A Marks: 2 Each.

(a)List some feature of .NET technology?

(b)What does a form Module contain?


(c)What is the
difference between a compile-time error and a run time error?

(d)What is the difference between an Integer and a Currency Variable?

(e)Write the line of code that adds your name to a list box name dIstnames.

(f)What do you mean by the term CLR?

(g)What starts the execution of an event procedure?

(h)List the primary components of the .NET Framework.

(i)List the control needed to create toolbar?

(m)Differentiate between decision and looping statements?

(n)What do you mean by broad cast scope of a Variable?

(o)Differentiate between a function and subroutine.

Section-B Marks: 5 Each

1 .Draw appropriate diagrams and discuss the various components of the .NET platform and the
architecture of the .NET Framework.

2. Explain with the help of suitable example that how you pass an array to procedures?

3. Briefly discuss the common Language Runtime and its components?

4. Write a note on `XML as the .NET meta Language`.

5. What do you mean by assemblies in .NET? List all the different types of assembling?

6. What are the classes and objects? Discuss how to add properties, events and methods to a class module.

7. Write the code for setting the Text property of a control named txt number to an empty text string.

8. What is the difference between a variable that has local scope and one that has global scope?

9. What do you mean by term procedure? How many types of procedures exist in VB?

10. Explain in detail, using an appropriate programming example, the use of events?

11. Can you define multiple Catch blocks in structured error handling? Explain.

12. In which way Visual Basic .NET can be used for writing windows applications? Explain with the help
of suitable example?
Question Bank
.NET Technology
1. Describe the
role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other
things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter
aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

2. What’s the difference between Response.Write() andResponse.Output.Write()?


Response.Output.Write() allows you to write formatted output.

3. What methods are fired during the page load?


Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.

4. When during the page processing cycle is ViewState available?


After the Init() and before the Page_Load(), or OnLoad() for a control.

5. What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page

6. Where do you store the information about the user’s locale?


System.Web.UI.Page.Culture

7. What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?


CodeBehind is relevant to Visual Studio.NET only.

8. What’s a bubbled event?


When you have a complex control, like DataGrid, writing an event processing routine for each
object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers,
allowing the main DataGrid event handler to take care of its constituents.

9. Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.
Where do you add an event handler?
Add an OnMouseOver attribute to the button. Example:
btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");

10. What data types do the RangeValidator control support?


Integer, String, and Date.
11. Explain the
differences between Server-side and Client-side code?
Server-side code executes on the server. Client-side code executes in the client's browser.

12. What type of code (server or client) is found in a Code-Behind class?


The answer is server-side code since code-behind is executed on the server. However, during the
code-behind's execution on the server, it can render client-side code such as JavaScript to
be processed in the clients browser. But just to be clear, code-behind executes on the server, thus
making it server-side code.

13. Should user input data validation occur server-side or client-side? Why?
All user input data validation should occur on the server at a minimum. Additionally, client-side
validation can be performed where deemed appropriate and feasable to provide a richer, more
responsive experience for the user.

14. What is the difference between Server.Transfer and Response.Redirect? Why would I
choose one over the other?
Server.Transfer transfers page processing from one page directly to the next page without making
a round-trip back to the client's browser. This provides a faster response with a little less overhead
on the server. Server.Transfer does not update the clients url history list or current url.
Response.Redirect is used to redirect the user's browser to another page or site. This performas a
trip back to the client where the client's browser is redirected to the new page. The user's browser
history list is updated to reflect the new address.

15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Valid answers are:
· A DataSet can represent an entire relational database in memory, complete with tables, relations,
and views.
· A DataSet is designed to work without any continuing connection to the original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded on demand.
· There's no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each loops to move through the data.
· You can store many edits in a DataSet, and write them to the original data source in a single
operation.
· Though the DataSet is universal, other objects in ADO.NET come in different versions for
different data sources.

16. What is the Global.asax used for?


The Global.asax (including the Global.asax.cs file) is used to implement application and session
level events.

17. What are the Application_Start and Session_Start subroutines used for?
This is where you can set the specific variables for the Application and Session objects.
18. Can you
explain what inheritance is and an example of when you might use it?
When you want to inherit (use the functionality of) another class. Example: With a base class
named Employee, a Manager class could be derived from the Employee base class.

19. Whats an assembly?


Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN

20. Describe the difference between inline and code behind.


Inline code written along side the html in a page. Code-behind is code written in a separate file and
referenced by the .aspx page.

21. Explain what a diffgram is and a good use for one?


The DiffGram is one of the two XML formats that you can use to render Dataset object contents to
XML. A good use is reading database data to an XML file to be sent to a Web Service.

22. What MSIL, and why should my developers need an appreciation of it if at all?
MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted
to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed
computer.

23. Which method do you invoke on the Data Adapter control to load your generated dataset
with data?
The Fill() method.

24. Can you edit data in the Repeater control?


No, it just reads the information from its data source.

25. Which template must you provide, in order to display data in a Repeater control?
ItemTemplate.

26. How can you provide an alternating color scheme in a Repeater control?
Use the AlternatingItemTemplate.

27. What property must you set, and what method must you call in your code, in order to bind
the data from a data source to the Repeater control?
You must set the DataSource property and call the DataBind method.

28. What base class do all Web Forms inherit from?


The Page class.
29. Name two
properties common in every validation control?
ControlToValidate property and Text property.

30. Which property on a Combo Box do you set with a column name, prior to setting the
DataSource, to display data in the combo box?
DataTextField property.

31. Which control would you use if you needed to make sure the values in two different controls
matched?
CompareValidator control.

32. How many classes can a single .NET DLL contain?


It can contain many classes.

Web Service Questions

1. What is the transport protocol you use to call a Web service?


SOAP (Simple Object Access Protocol) is the preferred protocol.

2. True or False: A Web service can only be written in .NET?


False

3. What does WSDL stand for?


Web Services Description Language.

4. Where on the Internet would you look for Web services?


http://www.uddi.org

5. True or False: To test a Web service you must create a Windows application or Web
application to consume this service?
False, the web service comes with a test page and it provides HTTP-GET method to test.

State Management Questions

1. What is ViewState?
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page.
ViewState is transported to the client and back to the server, and is not stored on the server or any
other external source. ViewState is used the retain the state of server-side objects between
postabacks.
2. What is the
lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks (to the
same page).

3. What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side
values for a given control into ViewState, which is stored as a hidden value on the page before
sending the page to the clients browser. When the page is posted back to the server the server
control is recreated with the state stored in viewstate.

4. What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the
session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so
that the user is always reconnected to the same web server. Out-of-Process Session state
management stores data in an external data source. The external data source may be either a SQL
Server or a State Server service. Out-of-Process state management requires that all objects stored
in session are serializable.

Vous aimerez peut-être aussi