dimanche 28 février 2016

Convert random to int visual studio 2015

why is this not working? It is in visual studo 2015, windows forms application C#

namespace guessing
{
    public partial class Form1 : Form
    {
        Random rnd = new Random();
        int rndm = rnd.Next(1, 13);

there is an error under rnd, which says:

"A field initializer cannot reference the non-static field, method, or property 'Form1.rnd' "




Aucun commentaire:

Enregistrer un commentaire