c# - Class does not contain a definition for object, even though I have initialised the object -
c# - Class does not contain a definition for object, even though I have initialised the object -
myclass[] myobject = new myclass[n]; int counter = 0; while (counter < myclass.myobject.length) { myclass.myobject[counter] = new myclass(); }
above illustration of i'm trying in current project of mine (obviously i've renamed object , class in illustration create clearer).
my problem i'm getting error when trying compile -- error given compiler on while condition:
cs0117; 'myclass' not contain definition 'myobject'.
i'm attempting straight in main() method, , due nature of project, must initialise object array, while loop initantiates each index of array object of class.
i don't understand why compiler not recognizing array, though beingness created right before while loop. can tell me dumb error i'm making?
remove myclass.
in next lines:
while (counter < myclass.myobject.length) { myclass.myobject[counter] = new myclass(); }
should be:
while (counter < myobject.length) { myobject[counter] = new myclass(); }
when utilize syntax myclass.something
means refer fellow member of myclass
called something
. there no such member.
c# arrays class oop object
Comments
Post a Comment