29 Ocak 2016 Cuma

Listbox eleman silme

try
{
//listboxda seçileni silmek için
int index = listBox1.SelectedIndex; // index değerini aldık
listBox1.Items.Remove(listBox1.SelectedItems[index]);
// alınan index değerine göre siler ( mouse ile istediğini seçmen lazm )
MessageBox.Show("silme başarılı");
}
catch
{
MessageBox.Show("Birşey Seç Lütfen");
}

c# email kontrol

public void emailkontrol(string emailadress)
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + // email tip
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(emailadress)) // eğer gelen veri email tpinde ise
{
MessageBox.Show("Email formatında(UYGUN)");
}
else
{
MessageBox.Show("Email Formatında değil!");
}
}

28 Ocak 2016 Perşembe

c# paralel

List<string> sites = new List<string>
{
"www.yahoo.com",
"www.google.com",
"www.aspsnippets.com"
};
 
List<PingReply> pingReplies = new List<PingReply>();
System.Threading.Tasks.Parallel.ForEach(sites, site =>
{
    Ping p = new Ping();
    lock (pingReplies)
    {
        pingReplies.Add(p.Send(site));
    }
});
 
foreach (var s in pingReplies.ToList())
{
    Response.Write(s.Address + ": " + s.RoundtripTime + ": " + s.Status + "<br />");
}

c# list

string[] lines = File.ReadAllLines(txtProxyListPath.Text);
List<string> list_lines = new List<string>(lines);
Parallel.ForEach(list_lines, line =>
{
    //Your stuff
});

c# task

async Task<int> AccessTheWebAsync()
{ 
    // You need to add a reference to System.Net.Http to declare client.
    HttpClient client = new HttpClient();

    // GetStringAsync returns a Task<string>. That means that when you await the
    // task you'll get a string (urlContents).
    Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");

    // You can do work here that doesn't rely on the string from GetStringAsync.
    DoIndependentWork();

    // The await operator suspends AccessTheWebAsync.
    //  - AccessTheWebAsync can't continue until getStringTask is complete.
    //  - Meanwhile, control returns to the caller of AccessTheWebAsync.
    //  - Control resumes here when getStringTask is complete. 
    //  - The await operator then retrieves the string result from getStringTask.
    string urlContents = await getStringTask;

    // The return statement specifies an integer result.
    // Any methods that are awaiting AccessTheWebAsync retrieve the length value.
    return urlContents.Length;
}


Trace an async program
The numbers in the diagram correspond 

26 Ocak 2016 Salı

yandex api

<script src=”http://code.jquery.com/jquery-1.10.2.js”></script >
<script>
jQuery( document ).ready(function() {
jQuery.ajax({
url: “https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20140720T191145Z.05605441c6ee16dc.eaaf6c6c8690cb5fb094cea2bfec4f787af6170c&lang=fr-en&text=C%27est+la+question”&#8221;,
dataType: ‘jsonp’,
success: function (data) {
alert(‘French to English Conversion : ‘+data.text);
}
});
});
</script>

24 Ocak 2016 Pazar

shell32

  1. Right click project
  2. Click Add reference
  3. Click .COM tab in Add reference dialogue
  4. Select Microsoft Shell Controls and Automation

c# zip işlemi

using System;
using System.IO;
using System.IO.Compression;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string startPath = @"c:\example\start";
            string zipPath = @"c:\example\result.zip";
            string extractPath = @"c:\example\extract";

            ZipFile.CreateFromDirectory(startPath, zipPath);

            ZipFile.ExtractToDirectory(zipPath, extractPath);
        }
    }
}

net 4.5 gereklidir.

c# yüklü programların listesi


public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
             
 
    private void LoadSoftwareList() 
    { 
        listBox1.Items.Clear(); 
        ManagementObjectCollection moReturn;   
        ManagementObjectSearcher moSearch; 
 
        moSearch = new ManagementObjectSearcher("Select * from Win32_Product"); 
 
        moReturn = moSearch.Get(); 
       foreach(ManagementObject mo in moReturn) 
       { 
           listBox1.Items.Add(mo["Name"].ToString()); 
       } 
 
    } 
 
 
        private void Form1_Load(object sender, EventArgs e) 
        { 
            LoadSoftwareList(); 
        }

c# açık olan formların ismi

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9. using System.Data.SqlClient;  
  10. namespace WindowsFormsApplication1  
  11. {  
  12.     public partial class Form3 : Form  
  13.     {  
  14.         public Form3()  
  15.         {  
  16.             InitializeComponent();  
  17.         }  
  18.   
  19.         private void Form3_Load(object sender, EventArgs e)  
  20.         {  
  21.             label3.Text = Application.OpenForms.Count.ToString();  
  22.             foreach (Form frm in Application.OpenForms)  
  23.             {  
  24.                 label1.Text = frm.Name;  
  25.             }  
  26.         }  
  27.   
  28.         private void button1_Click(object sender, EventArgs e)  
  29.         {  
  30.             Form1 frm1 = new Form1();  
  31.             frm1.Show();  
  32.         }  
  33.   
  34.         private void button2_Click(object sender, EventArgs e)  
  35.         {  
  36.             Form2 frm2 = new Form2();  
  37.             frm2.Show();  
  38.         }  
  39.   
  40.         private void button3_Click(object sender, EventArgs e)  
  41.         {  
  42.             label3.Text = Application.OpenForms.Count.ToString();  
  43.             label1.Text = "";  
  44.             foreach (Form frm in Application.OpenForms)  
  45.             {  
  46.                 label1.Text += frm.Name + "\n";  
  47.             }  
  48.         }  
  49.     }  
  50. }