KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a a class that has an integer array property and I am trying to figure out the right syntax for it. The integer array gets instantiated in the class constructor. class DemoClass { private int[] myNumbers; public int[] MyNumbers { get { /* Some logic */ } set { /* Some logic */ } } public DemoClass(int elements) { // Here, the array should get instantiated using the elements. } } How does the get/set block syntax work if I want my client code to retrieve a number from the array through the property MyNumbers ? How can I send it the right index? What do I have to initialize?
Tags (comma-separated)
Save Edits
Cancel