ERROR: CS0120: An object reference is required for the nonstatic field, method, or property

02 Temmuz 2009 – 12:15

Eğer farklı formlardaki verileri başka bir sınıf içinden erişip değiştirmek istediğinizde “ERROR: CS0120: An object reference is required for the nonstatic field, method, or property” hatası ile karşılaşıyorsanız

namespace Deneme
{
class Islemler
{

public Form1 MainForm { get; set; } // bu ifadeyi ekliyoruz
…………
…………
…………
int veriSayisi = MainForm.listView2.Items.Count ;
// şeklinde kullanımlar
MainForm.listView2.Items.RemoveAt // yapabilirsiniz

…………
…………
…………


}
}

Şeklinde bir kullanım yapılabilir.

Bookmark and Share

Post a Comment

Subscribe without commenting