You are on page 1of 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ArraysLesson
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
string[] doloohonog = new string[7];
doloohonog[0] = "даваа";
doloohonog[1] = "мягмар";
doloohonog[2] = "лхагва";
doloohonog[3] = "Пүрэв";
doloohonog[4] = "Баасан";
doloohonog[5] = "Бямба";
doloohonog[6] = "Ням";
//doloohonog array dah ugugduluudiig foreach eer listbox ruu
foreach(string honog in doloohonog)
{
listBox1.Items.Add(honog);
}
//label1 deer doloohonog array heden itemtaig hevlene
label1.Text = doloohonog.Length.ToString();
label2.Text = doloohonog[4];//index eer ne handna
//array initializer buyu array-d utga onoogch
int[] toonuud = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
//for davtaltaar tooonuud array iin ugugduluudiig listbox ruu
//hevlene
for(int i=0;i<toonuud.Length;i++)
{
listBox2.Items.Add(toonuud[i]);
}
int[] mytoonuud = new int[6] { 28, 29, 140, 19, 14, 21 };
int niilber = 0;
foreach(int too in mytoonuud)
{
if(too%2==0)
{
niilber = niilber + too;
listBox3.Items.Add(too);

}
}
label3.Text = niilber.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text.Trim()=="")
{
MessageBox.Show("haih gunjiin ner oruulna uu");
}
else
{
string[] gunjuud = new string[6]
{"Ariel","Bell","Cinderella","SnowWhite","Jasmin","Elsa"};
bool gunjoldloo = false;
foreach(string gunj in gunjuud)
{
if(gunj==textBox1.Text.Trim())
{
gunjoldloo = true;
MessageBox.Show(gunj);
break;//tasalduulah command
}
}
if(gunjoldloo==false)
{
MessageBox.Show("NO RESULT");
}

}
}

private void button2_Click(object sender, EventArgs e)


{
//games folder dah file uud myfiles arrayd hadgalagdsan
string[] myfiles = Directory.GetFiles(@"D:\\Games");
pictureBox1.ImageLocation = myfiles[3];
label4.Text = "array iin urt ne:" + myfiles.Length;
}
}
}

You might also like