Gad Theory

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

What is .

NET Framework

It is a virtual machine that provide a common platform to run an application that


was built using the different language such as C#, VB.NET, Visual Basic, etc.

It is also used to create a form based, console-based, mobile and web-based


application or services that are available in Microsoft environment.

.NET framework is a pure object oriented, that similar to the Java language. But it
is not a platform independent as the Java. So, its application runs only to the
windows platform.

The main objective of this framework is to develop an application that can run on
the windows platform.

Components of .NET Framework

CLR (common language runtime)

It is an important part of a .NET framework that works like a virtual component of


the .NET Framework to executes the different languages program like c#, Visual
Basic, etc. A CLR also helps to convert a source code into the byte code, and this
byte code is known as CIL (Common Intermediate Language) or MSIL (Microsoft
Intermediate Language). After converting into a byte code, a CLR uses a JIT
compiler at run time that helps to convert a CIL or MSIL code into the machine or
native code.

Microsoft intermediate language (MSIL)

Microsoft Intermediate Language (MSIL) is the assembly language output by .NET


compilers-C#, VB.NET, etc.

.NET framework is shipped with compilers of all programming languages to


develop programs. There are separate compilers for the visual basic, C#, and
visual programming languages in .NET framework. Each .NET compiler produces
an intermediate code after compiling the source code. The intermediate code
after compiling the source code. The intermediate code is common for all
environments. This intermediate code is known as Microsoft intermediate
language (MSIL).

A just-in-time (JIT) compiler

Is a program that turns bytecode into instructions that can be sent directly to a
computer's processor (CPU). Typically, compilers are key in deciding the speed of
an application for developers and end users. Just-in-time compilers can be used
for performance optimization to improve application runtime.

the main defining characteristic of a JIT compiler is that a JIT compiler runs after a
program starts and compiles code. A common way to say this is that a JIT
compiler compiles code on the fly, or in other words, just in time. The compiled
code, or bytecode sequences, are turned into a faster, more readable machine
language, or native code.

What is a namespace?

Namespaces are a way to define the classes and other types of information into
one hierarchical structure. System is the basic namespace used by every .NET
code. If we can explore the System namespace little bit, we can see it has lot of
namespace user the system namespace. For example, System.Io, System.Net,
System.Collections, System.Threading, etc.

A namespace can be created via the Namespace keyword. Here is an example to


create "Books" namespace in VB.NET and C#.

VB.NET Code:

Namespace Books
Class Authors
'Do something
End Class
End Namespace

A Data Type refers to which type of data or value is assigning to a variable or


function so that a variable can hold a defined data type value. For example, when
we declare a variable, we have to tell the compiler what type of data or value is
allocated to different kinds of variables to hold different amounts of space in
computer memory.

Syntax:

Dim Variable_Name as DataType

VariableName: It defines the name of the variable that you assign to store values.

Data Types Required Space


Boolean A Boolean type depends on the implementing
platform
Byte 1 byte
Char 2 bytes
Date 8 bytes

Decimal 16 bytes

Double 8 bytes

Integer 4 bytes
Long 8 bytes
Object Object size based on the platform such as 4 bytes
in 32-bit and 8 bytes in 64-bit platform

Operators in VB.net

 Arithmetic Operators
 Comparison Operators
 Logical/Bitwise Operators
 Bit Shift Operators
 Assignment Operators

Arithmetic operators

^ Raises one operand to the power of another

+ Adds two operands

- Subtracts second operand from the first

* Multiplies both operands

/ Divides one operand by another and returns a


floating point result

\ Divides one operand by another and returns an


integer result

MOD Modulus Operator and remainder of after an


integer division
Comparison operators

= Checks if the values of two operands are equal or not; if (A = B) is


yes, then condition becomes true. not true.

<> Checks if the values of two operands are equal or not; if (A <> B) is
values are not equal, then condition becomes true. true.

> Checks if the value of left operand is greater than the (A > B) is
value of right operand; if yes, then condition becomes not true.
true.

< Checks if the value of left operand is less than the value of (A < B) is
right operand; if yes, then condition becomes true. true.

>= Checks if the value of left operand is greater than or equal (A >= B) is
to the value of right operand; if yes, then condition not true.
becomes true.

<= Checks if the value of left operand is less than or equal to (A <= B) is
the value of right operand; if yes, then condition becomes true.
true.

Logical operators

And The And Operator represents, whether both the operands are true; (A And B),
the result is True. result = False

Or It is an Or Operator that returns a true value; if anyone operand is (A Or B),


true from both the operands. result = True

Not The Not Operator is used to reverse the logical condition. For Not A
example, if the operand's logic is True, it reveres the condition and
makes it False. Or

Not(A And B)
is True

Xor It is an Exclusive OR Operator that represents, whether both the A Xor B is


expression is true or false, the result is True; otherwise, the result True
is False.

Assignment Operators in VB.NET

Operator Description Example

= It is a simple assignment Operator used to assign X = 5, X assign a value 5


a right-side operand or value to a left side X = P + Q, (P + Q)
operand. variables or value assign
to X.

+= An Add AND assignment Operator is used to add X += 5, which means


the value of the right operand to the left X= X+5 ( 5 will add and
operand. And the result is assigned to the left assign to X and then
operand. result saved to Left X
operand)

-= It is a Subtract AND assignment Operator, which X -= P, which is same as X


subtracts the right operand or value from the = X - P
left operand. And then, the result will be
assigned to the left operand.

*= It is a Multiply AND assignment Operator, which X *= P, which is same as


multiplies the right operand or value with the X = X - P
left operand. And then, the result will be
assigned to the left operand.

Control structures in vb.net


In VB.NET, the control statements are the statements that controls the execution
of the program on the basis of the specified condition. It is useful for determining
whether a condition is true or not. If the condition is true, a single or block of
statement is executed. In the control statement, we will use if- Then, if Then Else,
if Then ElseIf and the Select case statement.

Loops in VB.net
VB.Net provides following types of loops to handle looping requirements. Click
the following links to check their details.

Loop Type Description

Do Loop It repeats the enclosed block of statements while a


Boolean condition is True or until the condition
becomes True. It could be terminated at any time
with the Exit Do statement.

For...Next It repeats a group of statements a specified number


of times and a loop index counts the number of loop
iterations as the loop executes.

For Each...Next It repeats a group of statements for each element in


a collection. This loop is used for accessing and
manipulating all elements in an array or a VB.Net
collection.

While... End While It executes a series of statements as long as a given


condition is True.
VB.NET Form Controls

A Form is used in VB.NET to create a form-based or window-based application.


Using the form, we can build a attractive user interface. It is like a container for
holding different control that allows the user to interact with an application. The
controls are an object in a form such as buttons, Textboxes, Textarea, labels, etc.
to perform some action.

VB.NET Classes and Object

A class is a group of different data members or objects with the same properties,
processes, events of an object, and general relationships to other member
functions.

Objects are the basic run-time units of a class. Once a class is defined, we can
create any number of objects related to the class to access the defined properties
and methods. For example, the Car is the Class name, and the speed, mileage, and
wheels are attributes of the Class that can be accessed by the Object.

Creating the Class

We can create a class using the Class keyword, followed by the class name. And
the body of the class ended with the statement End Class.

Constructor and Destructor

In VB.NET, the constructor is a special method that is implemented when an


object of a particular class is created. Constructor is also useful for creating and
setting default values for a new object of a data member.

When we create a class without defining a constructor, the compiler


automatically creates a default constructor. In this way, there is a constructor that
is always available in every class. Furthermore, we can create more than one
constructor in a class with the use of New keyword but with the different
parameters, and it does not return anything.
Parameterized Constructor

In VB.NET, when we pass one or more arguments to a constructor, the


constructor is known as a parameterized constructor. And the object of the class
should be initialized with arguments when it is created.

VB.NET Destructor

In VB.NET, Destructor is a special function that is used to destroy a class object


when the object of the class goes out of scope. It can be represented as
the Finalize() method and does not accept any parameter nor return any value.
Furthermore, it can be called automatically when a class object is not needed.

Inheritance in vb.net
Inheritance is a fundamental principle of object-oriented programming. It allows a
class to inherit the behavior or characteristics from base class to child class.

 It is a concept in which you define parent classes and child classes.


 The child classes inherit methods and properties of the parent class, but at
the same time, they can also modify the behavior of the methods if
required.
 The child class can also define methods of its own if required.
 The Inherits statement is used to declare a new class, called a derived
class, based on an existing class, known as a base class.
 Inherits statement: Specifies the base class.
 NotInheritable modifier: Prevents programmers from using the class as a
base class.
 MustInherit modifier: Specifies that the class is intended for use as a base
class only. Instances of MustInherit classes cannot be created directly;
they can only be created as base class instances of a derived class.
Overloading, overriding, and shadowing are also important concepts in Visual
Basic OOP.
 Overloaded—Overloaded members provide different versions of a property or
method that have the same name, but that accept different number of
parameters (or parameters of different types).
 Overridden—Overridden properties and methods are used to replace an
inherited property or method. When you override a member from a base
class, you replace it. Overridden members must accept the same data type
and number of arguments.
 Shadowed—Shadowed members are used to create a local version of a
member that has broader scope. You also can shadow a type with any other
type. For example, you can declare a property that shadows an inherited
method with the same name.

ADO.net
ADO.NET provides a bridge between the front end controls and the back
end database. The ADO.NET objects encapsulate all the data access
operations and the controls interact with these objects to display data, thus
hiding the details of movement of data.

ADO.NET Framework Data Providers


Data provider is used to connect to the database, execute commands and retrieve the
record. It is lightweight component with better performance. It also allows us to place
the data into DataSet to use it further in our application.

The .NET Framework provides the following data providers that we can use in our
application.

.NET Framework data Description


provider

.NET Framework Data Provider It provides data access for Microsoft SQL Server. It requires
for SQL Server the System.Data.SqlClient namespace.
.NET Framework Data Provider It is used to connect with OLE DB. It requires
for OLE DB the System.Data.OleDb namespace.

.NET Framework Data Provider It is used to connect to data sources by using ODBC. It requires
for ODBC the System.Data.Odbc namespace.

.NET Framework Data Providers Objects


Following are the core object of Data Providers.

Object Description

Connection It is used to establish a connection to a specific data source.

Command It is used to execute queries to perform database operations.

DataReader It is used to read data from data source. The DbDataReader is a base class for all
DataReader objects.

DataAdapter It populates a DataSet and resolves updates with the data source. The base class for all
DataAdapter objects is the DbDataAdapter class.
What is data binding?
The ability of a control to bind to a single data element, such as a value in a
column in a dataset table

Types of data binding

Windows Forms can take advantage of two types of data binding: simple binding and
complex binding. Each offers different advantages.

Type of data Description


binding

Simple data The ability of a control to bind to a single data element, such as a value in a column in a
binding dataset table. Simple data binding is the type of binding typical for controls such as
a TextBox control or Label control, which are controls that typically only display a single value.

Complex The ability of a control to bind to more than one data element, typically more than one record
data in a database. Complex binding is also called list-based binding. Examples of controls that
binding support complex binding are the DataGridView, ListBox, and ComboBox controls.

You might also like