504
504
504
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) 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
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:
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
No. of Tutorial : 1
Text Book:
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 :
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
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.
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
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
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.
Introduction of VB.NET
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.
Lecture Number : 4
BY :
Reference :
1. Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002 Edition). Chap-3
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-
· 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.
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.
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
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
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
Concatenation C &
Bitwise
Lecture Number : 8
BY :
Reference : “Complete ReferencrVB.NET 2.0” , Tata McGraw Hill , Jeffery R. Shapiro. Chap-6
Lecture Number : 9
BY :
Reference : Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002
Edition). Chap-7
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.
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.
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
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
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.
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.
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
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
Lecture Number : 14
BY :
Reference : “ADO.NET IN A NUTSHELL”, OREILLY, Bill Hamilton & Matthew MacDonald”. Chap-1 - 6
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.
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
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-
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
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
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
1. MDI Application :
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
· Control state
· Hidden fields
· Cookies
· Query strings
· Application state
· Session state
· Profile Properties
[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]
· 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 :
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.
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.
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
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.
· Copying the value from the instance into the value-type variable.
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.
· Perform I/O.
· 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.
MCA- 504
.NET Technology
(Jul-Dec 2010)
Tutorial-3
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
End Class
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
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:
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.
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
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
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
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
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. 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
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. System.XML
2. System.Assembler
3. System.Reflection
4. System.IO
1. System.XML
2. System.Assembler
3. System.Reflection
4. System.IO
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. 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
Question Bank
(e)Write the line of code that adds your name to a list box name dIstnames.
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?
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.
5. What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
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();");
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.
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.
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.
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.
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.
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.
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.