Kod:
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;
namespace C_Sharp_Telefon_Numara_Listesi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
harfler.AddRange(new string[] { "ABC", "DEF", "GHIİ", "JKL", "MNOÖ", "PQRS", "TUÜV", "WXYZ" });
}
private **** btnTelefonNoGetir_Click(object sender, EventArgs e)
{
string telefonAdi ="";
if (txtTelefonNo.Text.Length > 8)
{
telefonAdi = txtTelefonNo.Text.Substring(3, 5);
}
else
{
telefonAdi = txtTelefonNo.Text.Substring(3);
}
string numara = GetNumber(telefonAdi);
MessageBox.Show("444" + numara, "Telefon Numarası", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public List harfler =new List ();
public string GetNumber(string ad)
{
List numara = new List();
string adnumara = "";
for (int i = 0; i < ad.Length; i++)
{
for (int j = 0; j < harfler.Count; j++)
{
if (harfler[j].Contains(ad[i].ToString().ToUpper()))
{
numara.Add(j+2);
}
}
}
for (int i = 0; i < 5; i++)
{
if (5 - numara.Count > i)
{
adnumara += "0";
}
else
{
adnumara += numara[i-(5-numara.Count)];
}
}
return adnumara;
}
}
}