Important Questions

Core Idea

.NET is Microsoft’s unified, cross-platform development platform that provides a managed runtime (CLR), language interoperability, and a rich class library for building modern applications.

1. Evolution of .NET

2-Mark Version

Long Answer Points

2. Components of .NET

Key Components

Visual Hierarchy

Languages (C#, VB.NET, F#)
  ↓
  CLS + CTS
  ↓
  CLR (JIT + GC + Security + EH)
  ↓
  Base Class Library
  

3. CLR – Common Language Runtime

2-Mark Version

CLR is the runtime engine that manages code execution. It provides JIT compilation, automatic memory management, security, and exception handling.

Important Features

Feature Description Mnemonic
JIT Compilation Converts MSIL to native code at runtime J
Garbage Collection Automatic memory management G
Exception Handling Structured error handling across languages E
Code Access Security Controls permissions of running code S
Thread Management Supports multithreading T
Type Safety Verifies type compatibility T
Metadata & Reflection Runtime inspection of code

Mnemonic: J-GET-SET

4. CLS – Common Language Specification

5. Assemblies (DLL/EXE) in .NET

2-Mark Version

An assembly is a compiled unit (DLL or EXE) containing MSIL, metadata, and resources. It is self-describing and does not require registry registration.

Key Points

Quick Reference Table

Term Full Form One-line Note
CTS Common Type System Defines all data types for interoperability
MSIL Microsoft Intermediate Language Platform-independent code generated by compiler
JIT Just-In-Time Compiler Converts MSIL to native code at runtime
Assembly Deployment unit with MSIL, metadata & manifest

Active Recall Questions


VB.NET Exam Notes

1. Components of VB.NET Development Environment

Key Components

Component Description
Visual Studio IDE Main development environment with code editor, designer, and debugger
Toolbox Contains controls (Button, TextBox, Label, etc.)
Solution Explorer Shows all files, forms, and projects in the solution
Properties Window Used to set properties of controls and forms
Code Editor Where you write VB.NET code (supports IntelliSense)
Form Designer Visual designer to design Windows Forms
Debugging Tools Breakpoints, Watch window, Immediate window, Error List

2-Mark Answer: The VB.NET development environment includes Visual Studio IDE, Toolbox, Solution Explorer, Properties Window, and Code Editor for designing and coding applications.


2. Variable Declaration in VB.NET

Implicit Declaration

Dim name ' Implicit (treated as Object)
  

Explicit Declaration

Dim name As String
  Dim age As Integer
  Dim salary As Decimal
  

Option Explicit

Option Explicit On
  

3. Variable Scope in VB.NET

Scope Declared Inside Accessible In Lifetime
Local Procedure / Function Only within that procedure Until procedure ends
Module-level Module / Form All procedures in that module Until application ends
Global/Public Module with Public Entire application Until application ends

Examples:

Public total As Integer ' Global scope
  Dim counter As Integer ' Module-level scope
  
  Private Sub Button1_Click(...)
  Dim i As Integer ' Local scope
  End Sub
  

4. Events in VB.NET

What are Events?

Events are actions triggered by the user or system (e.g., clicking a button, loading a form).

Adding an Event

  1. Go to Form Designer
  2. Double-click the control (e.g., Button) → Automatically creates the event
  3. Or use the Properties Window → Click the lightning icon (Events) → Double-click the desired event

Writing Event Code

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  MessageBox.Show("Button Clicked!")
  End Sub
  

Common Events

Control Common Event Purpose
Button Click When button is clicked
Form Load When form is loaded
TextBox TextChanged When text is modified
ComboBox SelectedIndexChanged When selection changes

2-Mark Answer: An event is an action performed on a control. Code is written inside event procedures like Button1_Click. Events can be added by double-clicking the control or through the Properties window.


Quick Revision Points

Active Recall Questions


ASP.NET

1. Difference Between ASP and ASP.NET

Feature ASP (Classic ASP) ASP.NET
Platform Server-side scripting language Framework for building web apps
Syntax VBScript, JavaScript C#, VB.NET, F#
State Management Session & Application objects ViewState, Session, Cache
Performance Lower, interpreted code Higher, pre-compiled code
Development Model Procedural Event-driven, component-based
Security Limited built-in features Stronger security features and controls
Ease of Use More on raw HTML and scripts Use of server controls, data binding
Support for MVC Not supported Full support for MVC architecture

2-Mark Answer: ASP is a server-side scripting language that uses VBScript/JavaScript, while ASP.NET is a framework that uses compiled languages like C# and VB.NET, providing better performance, state management, and architecture.


2. Validation Controls in ASP.NET

Purpose

Validation controls are used to ensure user input is valid before processing it on the server side. They enhance user experience by providing immediate feedback.

Types of Validation Controls

Control Type Description
RequiredFieldValidator Ensures a field is not empty
RangeValidator Validates that a value is within a specified range
RegularExpressionValidator Validates input based on a regex pattern
CompareValidator Compares values of two controls
CustomValidator Allows custom validation logic defined by user
ValidationSummary Displays a summary of all validation errors

Example


  
  
  

3. Methods to Deploy ASP.NET Solutions

Deployment Options

  1. Web Deployment Project
  1. File System Deployment
  1. Web Publishing Wizard
  1. Using Visual Studio
  1. Containerization (Docker)

2-Mark Answer: ASP.NET solutions can be deployed using Web Deployment Projects, File System deployments, Web Publishing Wizard, Visual Studio, or Docker containers.


4. Using Objects and Cookies in ASP.NET

Object Uses in ASP.NET

Working with Cookies

What are Cookies?

How to Use Cookies in ASP.NET

' Setting a Cookie
  Dim userCookie As HttpCookie = New HttpCookie("UserInfo")
  userCookie("Username") = "JohnDoe"
  userCookie.Expires = DateTime.Now.AddDays(1) ' Cookie expires in 1 day
  Response.Cookies.Add(userCookie)
  
  ' Retrieving a Cookie
  If Request.Cookies("UserInfo") IsNot Nothing Then
  Dim username As String = Request.Cookies("UserInfo")("Username")
  Response.Write("Welcome back, " & username)
  End If
  

2-Mark Answer: Cookies are small data stored on the client-side, useful for tracking user information. In ASP.NET, you can create, retrieve, and manage cookies through HttpCookie class.


Quick Revision Points

Active Recall Questions


1. ADO.NET Architecture

ADO.NET is a set of classes in the .NET Framework that enables communication between .NET applications and data sources, such as databases and XML files. The architecture can be broken down into several components:

Architecture Overview

Diagram Overview

[Application] → [Data Provider] → [DataSet]
  ↓
  [Data Adapter]
  

Key Benefits:


2. Uses of Class Provider

Class providers in ADO.NET are specialized classes that connect to specific types of data sources. They encapsulate details about how to communicate with the data source.

Examples of Class Providers

Uses:


3. DataReader

Overview

The DataReader provides a fast and efficient way to read data from a database in a forward-only manner. It is designed for scenarios where speed and performance are crucial.

Key Features

Usage Example

Dim conn As New SqlConnection(connectionString)
  Dim cmd As New SqlCommand("SELECT * FROM Employees", conn)
  conn.Open()
  Dim reader As SqlDataReader = cmd.ExecuteReader()
  While reader.Read()
  Console.WriteLine(reader("Name"))
  End While
  reader.Close()
  conn.Close()
  

4. DataAdapter

Overview

The DataAdapter serves as a bridge between a DataSet and a data source, populating the DataSet with data and managing changes made to it.

Key Functions

Usage Example

Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  Dim ds As New DataSet()
  adapter.Fill(ds, "Employees") ' Fills DataSet with data
  adapter.Update(ds, "Employees") ' Updates database with changes
  

5. DataSet

Overview

A DataSet is an in-memory representation of data that can hold multiple data tables and relationships. It is disconnected from the data source.

Key Features

Usage Example

Dim ds As New DataSet()
  Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  adapter.Fill(ds, "Employees") ' Fills DataSet
  

6. Data Manipulation

CRUD Operations

ADO.NET provides a set of methods for performing Create, Read, Update, and Delete (CRUD) operations on the data:

Example for Update Operation

Dim cmd As New SqlCommand("UPDATE Employees SET Salary = @Salary WHERE Id = @Id", conn)
  cmd.Parameters.AddWithValue("@Salary", newSalary)
  cmd.Parameters.AddWithValue("@Id", employeeId)
  conn.Open()
  cmd.ExecuteNonQuery() ' Executes the update command
  conn.Close()
  

7. Data Navigation

Navigation within DataGridViews

The DataGridView control provides a powerful interface to display and navigate through data.

Example

Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  Dim ds As New DataSet()
  adapter.Fill(ds, "Employees")
  dataGridView1.DataSource = ds.Tables("Employees") ' Bind DataSet to DataGridView
  

8. DataGridView Control

Overview

DataGridView is a control that displays data in a tabular format, allowing users to view and interact with data easily.

Features

Usage Example

The following example shows how to configure a DataGridView for displaying data:

' Assuming dataGridView1 is your DataGridView control
  dataGridView1.AutoGenerateColumns = True
  dataGridView1.ReadOnly = False
  dataGridView1.AllowUserToAddRows = False ' Disable adding new rows
  

Conclusion

ADO.NET provides a robust framework for working with data in .NET applications, enabling efficient data retrieval, manipulation, and navigation. Understanding its architecture and components is essential for creating data-driven applications.

Active Recall Questions


ADO.NET Exam Notes

1. ADO.NET Architecture

ADO.NET is a data access technology that provides a bridge between the front-end applications and back-end databases. Its architecture consists of the following components:

Key Components

Architecture Diagram

[Application] 
  ↓
  [Data Provider] → [DataSet] 
  ↓
  [Data Adapter]
  

Key Benefits:


2. Uses of Class Provider

Class providers in ADO.NET are specialized classes responsible for connecting to specific databases and executing commands.

Common Class Providers

Functions of Class Providers


3. DataReader

Overview

The DataReader is a lightweight, fast way to read data from a data source. It is designed for scenarios where fast, read-only access is essential.

Characteristics

Example Usage

Dim conn As New SqlConnection(connectionString)
  Dim cmd As New SqlCommand("SELECT * FROM Employees", conn)
  conn.Open()
  Dim reader As SqlDataReader = cmd.ExecuteReader()
  While reader.Read()
  Console.WriteLine(reader("Name")) ' Access data by column name
  End While
  reader.Close()
  conn.Close()
  

4. DataAdapter

Overview

The DataAdapter acts as a bridge between a DataSet and a data source for retrieving and saving data.

Functions

Example Usage

Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  Dim ds As New DataSet()
  adapter.Fill(ds, "Employees") ' Fills DataSet
  adapter.Update(ds, "Employees") ' Updates database with changes
  

5. DataSet

Overview

A DataSet is an in-memory representation of data that can contain multiple tables, their relationships, and can be used in a disconnected mode.

Key Features

Example Usage

Dim ds As New DataSet()
  Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  adapter.Fill(ds, "Employees") ' Fills DataSet with employee data
  
  Dim table As DataTable = ds.Tables("Employees")
  ' Access table data here
  

6. Data Manipulation

ADO.NET allows performing CRUD (Create, Read, Update, Delete) operations easily.

CRUD Operations

Example for Update Operation

Dim cmd As New SqlCommand("UPDATE Employees SET Salary = @Salary WHERE Id = @Id", conn)
  cmd.Parameters.AddWithValue("@Salary", newSalary)
  cmd.Parameters.AddWithValue("@Id", employeeId)
  conn.Open()
  cmd.ExecuteNonQuery() ' Executes the update command
  conn.Close()
  

7. Data Navigation

Data Navigation with DataGridView

The DataGridView control is an essential component for displaying data in a tabular format.

Features

Example Binding to DataGridView

Dim adapter As New SqlDataAdapter("SELECT * FROM Employees", conn)
  Dim ds As New DataSet()
  adapter.Fill(ds, "Employees")
  dataGridView1.DataSource = ds.Tables("Employees") ' Bind DataSet to DataGridView
  

8. DataGridView Control

Overview

The DataGridView control is a sophisticated grid for displaying and editing tabular data.

Key Features

Example Configuration

dataGridView1.AutoGenerateColumns = True
  dataGridView1.ReadOnly = False
  dataGridView1.AllowUserToAddRows = False ' Disable adding new rows
  

Conclusion

ADO.NET provides a robust and efficient way to interact with various data sources in .NET applications. Understanding its architecture and components is vital for creating effective data-driven applications.

Active Recall Questions