c# - Adding data to a list inside a class -


i want fill list<int> inside class can't work. (some / of code here

the class:

    class fiu     {         public int feleseg { get; set; }         public list<int> preferencia { get; set; }         public fiu (int _feleseg) : this()             {                 feleseg = _feleseg;             }         public fiu()         {             this.preferencia = new list<int>();         }     } 

the code:

        (int = 1; < 4; i++)         {             fiu ujfiu = new fiu(0);             (int j = 1; j < 4; j++)             {                 ujfiu.preferencia[j-1] = 1;                                   }         } 

the main goal filling excel, right doesn't put 1-s in. don't know what's wrong.
"argument out of range exception unhandled" error.

replace this:

ujfiu.preferencia[j-1] = 1;  

with this:

ujfiu.preferencia.add(1);  

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -