C# GetEnumerator Metodu

Posted: July 1, 2014 in C#
Tags:

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

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

ArrayList dersler;
IEnumerator Koleksiyon;

private void Form1_Load(object sender, EventArgs e)
{

dersler = new ArrayList(3);
dersler.Add(“fizik”);
dersler.Add(“kimya”);
dersler.Add(“din”);
Koleksiyon = dersler.GetEnumerator();
Koleksiyon.MoveNext();
textBox1.Text = Koleksiyon.Current.ToString();

}

private void button1_Click(object sender, EventArgs e)
{

bool sonuc = Koleksiyon.MoveNext();
if (sonuc == true)
textBox1.Text = Koleksiyon.Current.ToString();
else

MessageBox.Show(“dersler bitti…”);

}
}
}

Bu programda her butonu bastıgımzda sırayla textbox iceriginde derslerin elemanları yazacak.Elemanlar bittigi zaman dersler bitti yazısı ekrana gelecektir.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s