Professional Documents
Culture Documents
Practical File C#
Practical File C#
C#
VARNIT JAIN
0191BCA056
Q. Write a c# program to print Hello and your name in a separate line
Q. Write a c# program to that takes a number as input and print its multiplication table.
Q. Write a c# program to print the result of dividing two numbers.
Q. Write a c# program to find the second largest element in a single dimensional array.
Q. Write a c# program to demonstrate boxing and unboxing.
Q. Write a c# program to implement stack operations
Q. Write a c# program to find the sum of all the elements present in a jagged array of 3 inner array
Q. Design a simple calculator using Switch Statement in c#.
PART 2
Create Database
Create database userdata;
C=Create Table user_info
CREATE TABLE user_info( `id` INT NOT NULL AUTO_INCREMENT , `names` VARCHAR(50) NOT
NULL , `username` VARCHAR(20) NOT NULL , `password` VARCHAR(50) NOT NULL , PRIMARY KEY
(`id`)) ;
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
//add this for MessageBox
using System.Windows.Forms;
namespace LoginSysten
{
public class Config
{
string ConectionString = ""; // save connection string
public MySqlConnection connection = null;
public string server = "127.0.0.1";// MySQL host / ip of the computer
public string user = "root";// MySQL user
public string password = "";// MySQL password
DataSet ds;
DataTable dt;
public string Table = "user_info"; // initialize db table
public string ConnectionType = "";
string RecordSource = "";
DataGridView tempdata;
public Config()
{
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
//==================================================================================
====
}
catch (Exception err) { MessageBox.Show(err.Message); }
}
// function to bring selected results based on column name and row index
public string Results(int ROW, string COLUMN_NAME)
{
try
{
return dt.Rows[ROW][COLUMN_NAME].ToString();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
return "";
}
}
// function to bring selected results based on column index and row index
public string Results(int ROW, int COLUMN_NAME)
{
try
{
return dt.Rows[ROW][COLUMN_NAME].ToString();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
return dt.Rows[ROW][COLUMN_NAME].ToString();
}
}
dt = new DataTable(ConnectionType);
try
{
string command = RecordSource.ToUpper();
MySqlDataAdapter da = new MySqlDataAdapter(RecordSource, connection);
ds = new DataSet();
da.Fill(ds, ConnectionType);
da.Fill(dt);
tempdata = new DataGridView();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
Q. Write a c# program to deign window from that includes-list box, checked list box and radio button
A. using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms
[Browsable(false)]
e.Graphics.FillRectangle(BackBrush, this.ClientRectangle);
return;
}
if (e.Index == maxItem)
backRect.Height = this.ClientRectangle.Top +
this.ClientRectangle.Height - e.Bounds.Top;
e.Graphics.FillRectangle(BackBrush, backRect);
Brush textBrush;
RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal;
textBrush = SystemBrushes.GrayText;
RadioButtonState.UncheckedDisabled;
textBrush = SystemBrushes.GrayText;
RadioButtonState.UncheckedDisabled;
else
textBrush = SystemBrushes.FromSystemColor(this.ForeColor);
}
if (!string.IsNullOrEmpty(DisplayMember))
e.Graphics.DrawString(((System.Data.DataRowView)this.Items[e.Index])
[this.DisplayMember].ToString(),
else
e.Graphics.DrawString(this.Items[e.Index].ToString(),
e.DrawFocusRectangle();
Q. Write a c# program to design a form that include data grind view control
this.vendorTableAdapter.Fill(this.vendorDataSet.Vendor);