Solution this ;
You must add this code :
You must add this code :
client.Headers.Add("user-agent","Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20100101 Firefox/4.0");
Uri url = new Uri(urlAddress); WebClient client = new WebClient(); client.Headers.Add("user-agent","Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20100101 Firefox/4.0"); client.Encoding = System.Text.Encoding.UTF8; string html = client.DownloadString(url); return html;
using System.Text.RegularExpressions;
private const string MatchEmailPattern =
@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})#CODE#quot;;
private string mail = hakan@hakanöncel.com
private void button1_Click(object sender, EventArgs e)
{
bool retVal = false;
retVal = Regex.IsMatch(mail, MatchEmailPattern);
if (retVal)
{
MessageBox.Show("OK");
}
else
{
MessageBox.Show("FAIL");
}
}
string searchValue = "SpecifiedName";
// where 1 is the hardcoded cell index
var query = from GridViewRow row in GridView1.Rows
where row.Cells[1].Text == searchValue
select row;
GridViewRow result = query.FirstOrDefault();
string colName = "name";
int index = (from DataControlField col in GridView1.Columns
where col.HeaderText == colName
select GridView1.Columns.IndexOf(col)).FirstOrDefault();
// index used
var query = from GridViewRow row in GridView1.Rows
where row.Cells[index].Text == searchValue
select row;
GridViewRow result = query.FirstOrDefault();
Alternate index lookup: instead of using HeaderText you can use BoundField.int index = (from DataControlField col in GridView1.Columns
where ((BoundField)col).DataField == colName
select GridView1.Columns.IndexOf(col)).FirstOrDefault();
string name = "SpecifiedName";
var query = from DataGridViewRow row in dataGridView1.Rows
where row.Cells["name"].Value.ToString() == name
select row;
// the row will be returned by this or contain a default value if not found
DataGridViewRow result = query.FirstOrDefault();