C# kullanarak Guid ile sadece sayı üretmek (get only digit from guid if it is digit in guid)

    protected void btnOlustur_Click(object sender, EventArgs e)
    {
        lblKod.Text = KodOlustur();
    }


    public string KodOlustur()
    {
                    string kod = Guid.NewGuid().ToString();
           
            string sonKod = string.Empty;

            foreach (char item in kod)
            {
                if (char.IsNumber(item))
                {
                    sonKod += item;
                }
            }
           
            sonKod = sonKod.Substring(0, 6);
           
            return sonKod;

    }

Yorumlar