Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Need to print list method to textbox

I have code with list where i have all factors of given number by user when the detect that the given number isn't a prime number.

public static List<int> Del(int cislo)
    {
        List<int> delitele = new List<int>();
        int max = (int)Math.Sqrt(cislo);
        for (int x = 1; x <= max; ++x)
        {
            if (cislo % x == 0)
            {
                delitele.Add(x);
                if (x != cislo / x)
                {
                    delitele.Add(cislo / x);
                }
            }
        }
        return delitele;
    }

And i need to print these factors to textbox on screen.

    private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            double cislo;

            if (double.TryParse(textBox1.Text, out cislo))
            {
                if (JePrvo(cislo))
                {
                    textBox2.Text = "Zadali jste prvočíslo " + cislo;
                }
                else
                {
                    textBox2.Text = list print here

                }
            }
        }

I tried to do it with foreach and some other things, but it keeps writting me that i can't convert Del as a method to string. I know that I'm missing something, but I have no clue what i have to do.

Comments