PDA

View Full Version : خطا در برنامه سی شارپ (تابع foreach)



shikmusic3
دوشنبه 24 فروردین 1394, 19:45 عصر
سلام دوستان.لطفا بهم بگید که کجایه کد مشکل داره؟
من تو قسمت windows form aplication این برنامه رو اکی کردم ولی تابع foreach رو خطا میگیره
کسی بلده راهنماییم کنه؟
و یه چیزه دیگه.چون تازه اینجا ثبته نام کردم خوب وارد نیستم.برنامه ای هست که در مورد reqular باشه.مثلا کد برنامه ایمیل دهی
این خطا رو برسی کنید تشکر

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.Text.RegularExpressions;


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

private void button1_Click(object sender, EventArgs e)
{
string output = "";
// create regular expression
Regex expression =
new Regex(@"J.*\d[0-35-9]-\d\d-\d\d");
string string1 = "Jane's Birthday is 05-12-75\n" +
"Dave's Birthday is 11-04-68\n" +
"John's Birthday is 04-28-73\n" +

// match regular expression to string and
// print out all matches
foreach (Match myMatch in expression.Matches(string1))
output += myMatch.ToString() + "\n";
MessageBox.Show(output, "Using class Regex",
MessageBoxButtons.OK, MessageBoxIcon.Information);
} // end class RegexMatches

}
}