0% found this document useful (0 votes)
15 views3 pages

C# Practical Theory

The document provides a comprehensive guide on various C# programming concepts, including jagged arrays, methods using out and ref keywords, delegates, indexers, and collections like List and Dictionary. It also includes practical examples for Windows Forms applications and ADO.NET for database interactions. Each section demonstrates how to implement these concepts through code snippets and explanations.

Uploaded by

dehoce7350
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

C# Practical Theory

The document provides a comprehensive guide on various C# programming concepts, including jagged arrays, methods using out and ref keywords, delegates, indexers, and collections like List and Dictionary. It also includes practical examples for Windows Forms applications and ADO.NET for database interactions. Each section demonstrates how to implement these concepts through code snippets and explanations.

Uploaded by

dehoce7350
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

C# PRACTICAL THEORY

In C#, create and initialize a jagged array with 2 rows, where the first row
contains the elements 1 and 2, and the second row contains the elements 3 and 4.
In C#, write a method that uses the out keyword to assign a value to a variable.
Call the method and retrieve the assigned value using an out parameter.
In C#, write a method that uses the out keyword to assign a value to a variable.
Call the method and retrieve the assigned value using an out parameter.
In C#, create a class named Sample that implements an indexer to allow accessing
and modifying elements of a private integer array using array-like syntax.
In C#, declare a delegate named Greet, define a method SayHello() that prints
"Hello", and use the delegate to invoke that method.
In C#, declare and initialize a generic List<int> with a few elements.
In C#, create a Dictionary<string, int> to store names as keys and corresponding
ages as values. Add two entries: one for "Alice" with age 25 and one for "Bob" with
age 30.
In C#, create a delegate named Show and define two methods Msg1() and Msg2() that
print different messages. Use a multicast delegate to invoke both methods
sequentially.
In C#, access and store the first element of the second row in a jagged array into
an integer variable.
In C#, write a method that uses out parameters to return two integer values. Then
call the method and store the returned values in two variables.
In C#, create and initialize a jagged array with 2 rows, where the first row
contains the elements 1 and 2, and the second row contains the elements 3 and 4.
In C#, demonstrate how to use the 'ref' keyword to modify a variable's value within
a method.
In C#, write a method that uses the out keyword to assign a value to a variable.
Call the method and retrieve the assigned value using an out parameter.
In C#, create a class named Sample that implements an indexer to allow accessing
and modifying elements of a private integer array using array-like syntax.
In C#, declare a delegate named Greet, define a method SayHello() that prints
"Hello", and use the delegate to invoke that method.
In C#, declare and initialize a generic List<int> with a few elements.
In C#, create a Dictionary<string, int> to store names as keys and corresponding
ages as values. Add two entries: one for "Alice" with age 25 and one for "Bob" with
age 30.
In C#, create a delegate named Show and define two methods Msg1() and Msg2() that
print different messages. Use a multicast delegate to invoke both methods
sequentially.
In C#, access and store the first element of the second row in a jagged array into
an integer variable.
In C#, write a method that uses out parameters to return two integer values. Then
call the method and store the returned values in two variables.
Write a C# program to declare and initialize a jagged array with two rows, where
the first row contains two elements and the second contains three elements. Display
all elements.
Write a C# program that demonstrates the use of the ref keyword by creating a
method that adds 10 to a given integer. Call the method and print the updated
value.
Create a C# program using the out keyword to return two integer values from a
method. Print both values in the main method.
Implement a class in C# that uses an indexer to store and retrieve integer values
in a private array. Demonstrate storing and retrieving values using the indexer.
Create a simple delegate in C# that points to a method named SayHello which prints
"Hello!" to the console. Invoke the delegate to execute the method.
Write a C# program that demonstrates multicast delegates by creating two methods (A
and B) and calling them both using a single delegate.
Create a C# program using List<int> to add at least two numbers. Display the second
element from the list.
Write a C# program to create a dictionary that stores names (as strings) and their
corresponding ages (as integers). Display the age of a specific person (e.g.,
"Alice").
Write a C# program to demonstrate that a jagged array can contain inner arrays of
different lengths. Initialize and display the values.
Design a C# class with a string indexer that stores any string and returns it in
lowercase. Demonstrate storing a string in uppercase and retrieving it in lowercase
using the indexer.
Write a C# program to declare, initialize, and display the elements of a jagged
array with varying lengths.
Write a C# program to demonstrate the use of the ref keyword to pass a variable by
reference to a method and modify its value within the method.
Write a C# program to illustrate the use of the out keyword to return multiple
values from a method by passing variables as output parameters.
Write a C# program to implement indexers in a class. Demonstrate how an object can
be accessed like an array using an indexer.
Write a C# program using a delegate to call a method that prints a greeting message
with the given name.
Write a C# program to create a list of fruits, add "Apple", "Banana", and "Cherry"
to the list, and display each fruit using a foreach loop.
Write a C# program to compare the usage of ref and out keywords. Show how ref
requires initialization and out does not, and how both modify values through
methods.
Write a C# program to store integer values in a List<int>, sort the list using the
built-in Sort() method, and display the sorted values.
Write a C# program using a delegate to call two static methods Hello and Welcome
sequentially.
Write a C# program using Dictionary to store and display roll numbers and names of
students. Add at least two entries and print them using a foreach loop.
Write a C# Windows Forms code to display “Hello World” in a message box when
btnClick button is clicked.
Write a C# code to set the label1 text equal to the value entered in textBox1 when
the btnSetLabel button is clicked.
Write a C# code to set the label1 text equal to the value entered in textBox1 when
the btnSetLabel button is clicked.
Write a C# Windows Forms code to open a .txt file using OpenFileDialog, read its
content, and display it in textBox1 when a button is clicked.
Write a C# code using SaveFileDialog to save the content of textBox1 into a .txt
file when a button is clicked.
Write a C# code to set the current Windows Form as an MDI parent form.
Write a code to open a new instance of ChildForm inside the current MDI parent form
when a button is clicked.
Write a C# code to create a SQL Server database connection to the test database
using SqlConnection and open it.
Write a C# code using SqlCommand to insert a record with name ‘John’ into the
Student table using the open connection con.
Write a C# code to retrieve all records from the Student table using
SqlDataAdapter, fill the result into a DataTable object named dt.
Write a C# code to bind the DataTable object dt to a DataGridView control named
dataGridView1.
Write a C# Windows Forms program where textBox1 takes user input and on btnShow
click, displays it in label1.
Write a C# Windows Forms program that displays the selected item of comboBox1 in a
MessageBox when btnSubmit is clicked.
Write a C# program to read content from a text file using OpenFileDialog and
display it in textBox1 when btnOpen is clicked.
Write a C# program to save the content of textBox1 to a file using SaveFileDialog
when btnSave is clicked.
Write a C# program to make a form an MDI container and open a ChildForm inside it
when btnOpenChild is clicked.
Write a C# ADO.NET code to connect to SQL Server and insert a student named ‘John’
into the Student table using SqlConnection and SqlCommand.
Write a C# ADO.NET program to update a student name from ‘John’ to ‘Johnny’ in the
Student table.
Write a C# program to retrieve all student records using SqlDataAdapter and store
them in a DataTable.
Write a program to bind data from a DataTable to a DataGridView named dataGridView1
after fetching it using SqlDataAdapter.
Write a C# program to add a new row to a DataTable, and update the changes back to
the Student table using SqlCommandBuilder.
Create a Windows Forms application that takes a student's name from textBox1,
displays a welcome message in label1 when button1 is clicked.
Write a program that uses OpenFileDialog to open a text file and display its
content in textBox1.
Create a Windows Forms program that changes the background color of a form using
ColorDialog on button1 click.
Design an MDI Parent form with a menu item that opens a Child Form. Use MenuStrip
and MDI architecture.
Write a C# program to insert student data into a SQL Server table using Connected
Architecture.
Display records from the Student table in a DataGridView using Connected
Architecture.
Fetch and display data using SqlDataAdapter and DataSet (Disconnected Architecture)
in a DataGridView.
Insert a new row into DataTable, then update the database using SqlDataAdapter.

You might also like