Dot Net Framework
A)
Write a program in C#.Net to find the sum of all elements of the array.
Answer :
namespace WinFormsApp27
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
int a,b=0,c;
for(int i = 0; i < listBox1.Items.Count; i++)
{
a =
Convert.ToInt32(listBox1.Items[i]);
c = a + b;
b = c;
}
MessageBox.Show("Addtion is : "
+ b);
}
}
}
Output :
B)
Write a C#.Net Program to define a class Person having members –name, address.
Create
a subclass called employee with member staffed, salary. Create ‘n’ objects of
the
Employee
class and display all the details of the Employee.
Answer :
Output :
No comments:
Post a Comment