content

C#/Dotnet

Important Questions, Internal Assessment 2

Q1. Explain the If-Else statement in VB.NET and Give one example

If-Else, also known as If-Then-Else statements are used for basic conditional logic.

Syntax:

If condition Then
    statements
ElseIf condition2 Then
     More Statements
Else
     else statements
End If

Just like if statement, it is always followed by “End If” to show that the if-else block is over.

Example:

Dim n As Integer = 5

If n Mod 2 = 0 Then
    Console.WriteLine("Even")
Else
    Console.WriteLine("Odd")
End If

Official Microsoft Docs

Q2. What is the purpose of Time control?

The timer control is a looping control used to repeat any task in a given time interval. It is an important control used in Client-side and Server-side programming, also in Windows Services. It is used to execute an application after a specific amount of time. Once the timer is enabled, it generates a tick event handler to perform any defined task in its time interval property. [1]

Q3. What is the use of Track bar control in VB.NET?

The Windows Forms TrackBar control (also sometimes called a “slider” control) is used for navigating through a large amount of information or for visually adjusting a numeric setting.

Official Microsoft Docs

Q4. Write any two advantages of ADO.NET

ADO.NET(Active Data Objects .NET) is the database access framework used to connect to data sources like MS SQL Server, Microsoft Access, Oracle SQL, MySQL/MariaDB, SQLite, direct XML, etc

ADO.NET has many features like:

(GeeksForGeeks)

Q5. Explain looping statements in VB.NET

In Visual Basic, loop statements are used to run code repeatedly while the condition is maintained.

There are 4 types of Loops:

Official Microsoft Docs

Q6. Write the difference between ADO and ADO.NET

| ADO | ADO.NET | |—| — | | It is based on COM (Component Object Modelling). | It is a CLR (Common Language Runtime) based library. | | It works only when data store is connected. | It does not needs active connection to access data from data store. | | It has feature of locking. | It does not have feature of locking. | It access and store data from data source by recordset object. | It access and store data from data source by dataset object. | | XML integration is not feasible in ADO. | XML integration is feasible in ADO.NET. | | In ADO, data is stored in binary form. | While in this, data is stored in XML. | | It allow us to create client side cursors only. | It give us the choice of using weather client side and server side cursors. | | It requires SQL JOINs and UNIONs to combine data from multiple tables in a single result table. | It uses DataRelational objects, for combining data from multiple tables without requiring JOINs and UNIONs. | | It supports sequential access of rows in a RecordSet. | It allows completely non-sequential data access in DataSet through collection based hierarchy. |

GeeksForGeeks

Q7. Explain about combo box control and picture box control with an example

JavaTPoint

Q8. Explain Data reader and Data adapter in ADO.NET

DataReader

DataReader is a forward-only, read-only cursor used to retrieve a stream of data from a database.

Q9. Explain any 4 tools and its properties from toolbox of VB.NET

1. TextBox

Description: A TextBox control allows users to input and edit text. It is commonly used for forms where user input is required.

Properties:

Practical Use: A TextBox is often used in forms for input fields like name, email, or password. For example, in a login form, you would typically have two TextBox controls for the username and password.


2. ComboBox

Description: A ComboBox combines a drop-down list with an editable text box, allowing users to either select an item from a list or enter a custom value.

Properties:

Practical Use: A ComboBox is often used for selecting options from a predefined list, such as selecting a country from a list of countries in a registration form. It can also allow users to input custom values if needed.


3. ListBox

Description: A ListBox displays a list of items from which the user can select one or more items. It is useful for presenting a collection of options.

Properties:

Practical Use: A ListBox is often used to display options for selection, such as a list of available products in an e-commerce application. Users can select multiple items (e.g., multiple products) to add to their cart.


4. PictureBox

Description: A PictureBox control is used to display images in a Windows Forms application. It can show bitmaps, icons, or other types of images.

Properties:

Practical Use: A PictureBox is commonly used in applications that require image display, such as a photo viewer or an application that showcases product images. For instance, in a gallery application, each PictureBox can display a different image, allowing users to browse through a collection.

Q10. Explain subroutine and functions with the help of example

| Parameters | Sub Procedures | Functions | |————|—————-|———–| | 1 | A subprocedure is not associated with an event. | A function is also not associated with an event. | | 2 | A subprocedure is called whenever it is required to perform certain tasks. It returns control to the calling code after performing a task. | A function is called whenever a value is required to be returned to the calling code after performing a task. | | 3 | A subprocedure does not return a value to the calling code. | Functions return a value to the calling code. | | 4 | A subprocedure cannot be used with an expression. | Functions are used in an expression. | | 5 | A subprocedure helps to make the code readable, and easy to modify and debug. | In functions, it is not easy to modify and debug the code. | | 6 | A subprocedure is a generalized type of function. | A function is a specific type of procedure. | | 7 | A subprocedure is declared with the keyword Sub. | A function is declared with the keyword Function. |

[1]

Q11. Explain the architecture of ADO.NET

ADO.NET has two main components that are used for accessing and manipulating data are the .NET Framework data provider and the DataSet. [1]

Q12. What is Data set and Data Provider?

Q13. What is docking and undocking in visual studio?

Docking and undocking in Visual Studio for Windows Forms refers to the ability to arrange controls within a form. Docking allows a control to attach itself to one of the edges of its parent container, automatically resizing to fill the available space. This is useful for creating layouts that adapt to different form sizes and orientations. Undocking, on the other hand, allows a control to be separated from its parent container, enabling it to float freely or be moved to another location, such as a different monitor. [1]

Q14. Explain Task bar and Progress bar controls of VB.NET

Q15. Explain the steps to create a simple form using VB.NET

To create a Visual Basic application project. The project type comes with all the template files that you need.

Q16. Explain VB.NET Conditional and looping statements with a suitable example

Conditional Statements are already answered in Q1.

Q17. Explain Exception Handling in C# with example syntax

An exception is a problem that arises during the execution of a program. A C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. C# exception handling is built upon four keywords: try, catch, finally, and throw.

Syntax:

try {
   // statements causing exception
} catch( ExceptionName e1 ) {
   // error handling code
} catch( ExceptionName e2 ) {
   // error handling code
} finally {
   // statements to be executed
}