By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Object refernce is required for non-static, method or property

P: 18
Hi Everybody,

proj1-frmCatSql.cs contains a method like

public datatable GetallMembers() { stms--------- }

proj2-frmItem.cs conatins

private void Filldata(combobox cmb, datatable dtlname) { stmts------- }

private viod frmitem_load( ) {
Filldata( cmbcate, catesql.Getallmembers())

Note: catesql is class of frmCatsql.cs
Here I get an error at catesql.Getallmembers() as An object reference is required for non-static, method or property.

I can't make the method as static. B'coz itz referencing to another methods where they wer defined as Abstract and Override methods.

Please suggest me how to resolve these error. Hope everbody understood. Please send me as soon as possible
Jan 6 '09 #1
Share this Question
Share on Google+
1 Reply


100+
P: 344
use new keyword to instantiate an object

datatable x = (new catesql ( ) ).Getallmembers ( );
so the object will created and ended its lifetime at the same statement,
and you'll get your information x the datatable
Jan 6 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.