0
votes
public Urun(int id)
        {
            this.UrunId = id;

            List<Urun> dr = ManagementLib.UrunBilgisiAl(id, null, null, null, null, null, null, null, null, null, null, null, null, null, null);


            for (int i = 0; i < dr.Count; i++)
            {


                this.UrunId = Convert.ToInt32(dr["id"].ToString());

......

Error 1 The best overloaded method match for 'System.Collections.Generic.List.this[int]' has some invalid arguments

Error 2 Argument 1: cannot convert from String to int

2
Please add the language tag. - Paul Bellora

2 Answers

1
votes

List<T> does not support lookup by key. You need to use a Dictionary<string, URun>

1
votes

Error 1 The best overloaded method match for 'System.Collections.Generic.List.this[int]' has some invalid arguments

You're trying to access items on List<Urun> as a dictionary and that's not possible

dr["id"] //<-- this is not valid, a position is expected (dr[0], dr[1], etc)

I assume you're trying to do

this.UrunId = Convert.ToInt32(dr[i].id.ToString());

But I don't see the point honestly since on every iteration this.UrunId would be overwritten.