Vous êtes sur la page 1sur 7

CODES

using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] names = new string[5];
names[0] = "Diego";
names[1] = "Manny";
names[2] = "Anne";
names[3] = "Robert";
names[4] = "Kevin";
int ctr = 0;
foreach (string d in names)
{
MessageBox.Show("The Result for array of name:" + names[ctr]);
ctr++;
}
}

OUTPUT

CODES
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[,] Multinames = new string[2, 3] {
{"Ruiz","A.","Mariano"},
{"Dane","G.","Garcia"},
};
string[] fullname = new string[2];
fullname[0] = Multinames[0, 0] + Multinames[0, 1] + Multinames[0, 2];
fullname[0] = Multinames[1, 0] + Multinames[1, 1] + Multinames[1, 2];
int fullnameCounter = 0;
foreach (string n in fullname)
{
MessageBox.Show("The Result is:" + fullname[fullnameCounter]);
fullnameCounter++;
}

}
}

OUTPUT

CODES
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;

namespace WindowsFormsApplication3
{
public partial class frmStrings : Form
{
public frmStrings()
{
InitializeComponent();
}
//declaration for enum
enum Holidays { NewYear, AllSaintsDay, LaborDay, Christmas };
//declaration for struct
struct HolidaysStruct
{
public string Holiday;
};
private void btnShowEnumResult_Click(object sender, EventArgs e)
{
int NewYear = (int)Holidays.NewYear;
int AllSaintsDay = (int)Holidays.AllSaintsDay;
int LaborDay = (int)Holidays.LaborDay;
int Christmas = (int)Holidays.Christmas;
//passing values from listbox to an array.
string[] ListofHolidays = new string[] {lstHolidaysEnum.Items[0].ToString(),
lstHolidaysEnum.Items[1].ToString(),
lstHolidaysEnum.Items[2].ToString(),
lstHolidaysEnum.Items[3].ToString()};
MessageBox.Show(ListofHolidays[NewYear]);
MessageBox.Show(ListofHolidays[AllSaintsDay]);
MessageBox.Show(ListofHolidays[LaborDay]);
MessageBox.Show(ListofHolidays[Christmas]);
}
private void btnShowStructResult_Click(object sender, EventArgs e)
{
//initialization of struct
HolidaysStruct NewYearStruct = new HolidaysStruct();
HolidaysStruct AllSaintsDayStruct = new HolidaysStruct();
HolidaysStruct LaborDayStruct = new HolidaysStruct();
HolidaysStruct ChristmasStruct = new HolidaysStruct();
NewYearStruct.Holiday = lstHolidaysStruct.Items[0].ToString();
AllSaintsDayStruct.Holiday = lstHolidaysStruct.Items[1].ToString();

LaborDayStruct.Holiday = lstHolidaysStruct.Items[2].ToString();
ChristmasStruct.Holiday = lstHolidaysStruct.Items[3].ToString();
string[] ListofHolidaysStruct = new string[] { NewYearStruct.Holiday,
AllSaintsDayStruct.Holiday,
LaborDayStruct.Holiday,
ChristmasStruct.Holiday };
MessageBox.Show(ListofHolidaysStruct[0]);
MessageBox.Show(ListofHolidaysStruct[1]);
MessageBox.Show(ListofHolidaysStruct[2]);
MessageBox.Show(ListofHolidaysStruct[3]);
}

}
}

OUTPUT

COMPUTER
PROGRAM
MING

MADRID,JOY CHRISTIAN C,
BSIT/A308

Vous aimerez peut-être aussi