Gokaraju Rangaraju Institute of Engineering and Technology
Gokaraju Rangaraju Institute of Engineering and Technology
Gokaraju Rangaraju Institute of Engineering and Technology
TECHNOLOGY
VISUAL PROGRAMMING USING C# AND .NET LAB
Course Objectives:
1. To provide hands on experience on .Net framework.
2. To appreciate the asynchronous event handling feature in .Net.
3. To offer end-to-end program model for web application development.
4. To develop applications for the .NET Framework using C#
5.To learn C# debugging techniques
Course Outcomes:
1. Create Event Driven Applications.
2. Develop asynchronous applications
3. Deploy Web services
4. Build database applications using ADO.NET
5. Understand the Language Integrated Query (Linq) library
TASK1: Write a program to check weather a given number is palindrome using C#.NET.
TASK2: Create a program to implement a concept of Overloading using C#.NET.
TASK3: Write a program to store the employee details using class and methods in C# .NET
TASK4: Create a program to implement the concepts of OOPS for creating class, inheritance
TASK5: Create a Window Form using HTML Controls
TASK6: Perform String Manipulation with the String Builder and String Classes and C#:
Demonstrates some basic string manipulation using both the String Builder and String
classes.
TASK7: Demonstrate the concept of
a) Creating a Thread
b) Managing a Thread
c) Deleting a Thread
TASK8: Create a Sample program to Demonstrate Insertion of data into database.
TASK9: Create a Program to Demonstrate Color Dialog in C#.
TASK10: Create a program to perform validation using validation controls.
TASK11: Create a Sample program to Demonstrate creation and usage of Dynamic Link
Libraries in C#.
TASK12: Student Management System application development with required details: Use
ADO.NET for storing and manipulating the data. Develop the necessary forms for the better
user interface.
TASK1: Write a program to check weather a given number is palindrome using
C#.NET.
STEP1: Create a new file in Visual studio code and save it as task1.cs
using System;
public class P
{
public static void Main (string [] args)
{
int n,r,sum=0,temp;
Console.Write("Enter the Number: ");
n = int.Parse(Console.ReadLine());
temp=n;
while(n>0)
{
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
Console.Write("Number is Palindrome.");
else
Console.Write("Number is not Palindrome");
}
}
using System;
int sum2=ob.add(2,4);
Console.WriteLine("Sum of two integer value:"+sum2);
float sum4=ob.add(0.1f,0.3f,0.8f,0.1f);
Console.WriteLine("Sum of four flat value:"+sum4);
}
}
OUTPUT:
TASK3: Write a program to store the employee details using class and methods in
C# .NET.
using System;
}
}
class test
{
public static void Main(string[] args)
{
employee e1 = new employee();
int a;
string b;
float c;
Console.WriteLine("Enter the No.");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter name");
b=Convert.ToString(Console.ReadLine());
Console.WriteLine("Enter the salary.");
c=Convert.ToInt32(Console.ReadLine());
e1.insert(a,b,c);
e1.display();
}
}
OUTPUT:
TASK4: Create a program to implement the concepts of OOPS for creating class,
inheritance.
using System;
public class Employee
{
public float salary = 40000;
}
public class Programmer: Employee
{
public float bonus = 10000;
}
class TestInheritance{
public static void Main(string[] args)
{
Programmer p1 = new Programmer();
}
}
OUTPUT:
TASK5: Create a Window Form using HTML Controls
Step1: Check the dotnet version in the command Prompt by using below command
>dotnet –version
Step2: A new folder is to be created,
>dotnet new webapp -o MyWebApp --no-https -f net6.0
The dotnet new command creates a new application.
Several files were created in the MyWebApp directory to give you a simple web application
that is ready to run.
<div class="text-center">
<h1>Hello, world!</h1>
<p>The time on the server is @DateTime.Now</p>
</div>
Step4: again, goto cmd prompt and type commands:
cd MyWebApp
dotnet watch
Step5: A Output is displayed on the Window page(browser).
EXAMPLE PROGRAM
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with
ASP.NET Core</a></p>
<head>
<title>Table</title>
</head>
<body>
<table border="1" width="200" height="200">
<caption>Invoice</caption>
<tr>
<th>Sno</th>
<th>Item</th>
<th>Price</th>
</tr>
<tr>
<td>1</td>
<td>Apple</td>
<td>Rs. 20</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>Rs. 15</td>
</tr>
<tr>
<td>3</td>
<td>Banana</td>
<td>Rs. 3</td>
</tr>
</table>
</body>
</div>
OUTPUT:
TASK6: Perform String Manipulation with the String Builder and String Classes and
C#: Demonstrates some basic string manipulation using both the String Builder and
String classes.
using System;
using System.Text;
using System.Collections;
class stringbuilder {
// Concatenates to String
public static void concat1(String s1)
{
// taking a string which is to be Concatenated
String st = "To C#.NET Lab";
// using String.Concat method
// you can also replace it with
// s1 = s1 + "To C#.NET Lab";
s1 = String.Concat(s1, st);
}
// Concatenates to StringBuilder
public static void concat2(StringBuilder s2)
{
// using Append method of StringBuilder class
s2.Append("To C#.NET Lab");
}
// Main Method
public static void Main(String[] args)
{
String s1 = "Welcome";
concat1(s1); // s1 is not changed
Console.WriteLine("Using String Class: " + s1);
StringBuilder s2 = new StringBuilder("Welcome");
concat2(s2); // s2 is changed
Console.WriteLine("Using StringBuilder Class: " + s2);
}
}
OUTPUT:
TASK7: Demonstrate the concept of
a) Creating a Thread
b) Managing a Thread
c) Deleting a Thread
using System;
using System.Threading;
class Threading
{
static void Main()
{
Thread thr=new Thread(mythread);
Thread thr1=new Thread(mythread1);
Console.WriteLine("thread started");
thr.Start();
thr1.Start();
//thr.Abort();
//thr1.Abort();
Console.WriteLine("Thread ended");
}
}
}
static void mythread1()
{
for(int i=0;i<=10;i++)
{
if(i%2!=0 && i!=0)
Console.WriteLine(i+ "Odd");
Thread.Sleep(1000);
}
}
}
OUTPUT: