C# Indexer Wizard?

B

Bradley1234

Im trying to now manipulate arrays in C#

Point[] points = new Point[200];



for (int x = 0; x < 200; x++)

{

points[x] = { (20 + x) , ( += null) }; //any variation of brackets and commas fails.

}



Im trying to draw using Graphics DrawLines, which takes coordinates to draw a line from last to next, etc

Then trying to fill up an array of the 200 points with specific data. The use here is Point(int x1, int y1)

The format of the array of points is x1 = an offset of 20 added to the running value of the "x" in the for loop, and then y1 can be any value between 0 and 200.

Just trying to initialize the array to anything? has proven difficult, the array control doesnt seem as powerful as C

Then in a C# book, it says use the C# Indexer Wizard, simply right click on the class where your array is, and it gives you a wizard to construct what youre trying to do. But the one Im using has nothing like that...

Is this a common tool? Indexer Wizard? Or how are arrays managed in C# thats so different?



thanks
 
S

Stephen Brooker

Bradley1234 said:
Im trying to now manipulate arrays in C#


*Point[] points = new Point[200];*

* *

* for (int x = 0; x < 200; x++)*

* {*

* points[x] = { (20 + x) , ( += null) }; //any variation of
brackets and commas fails.*

*}*

**


points[x] = new Point(yourXValue, yourYValue)
 
B

Bradley1234

points[x] = new Point(yourXValue, yourYValue)

Wow, thanks it works! Now the code is

for (int x = 0; x < 200; x++)

{


points[x] = new Point((x += 0), (x += 030));


}

e.Graphics.DrawLines(pen, points);



Im so grateful for the assistance, and I just figured out how to leave one or the other part of the x.y in its place by just a reference

points[x] = new Point((x += 0), (points[x].Y));

cool.



And an odd side effect is that it draws 7 lines, starting at point 0,0 it makes a line straight down 15, the next one from 00 goes at an angle and stops at 30,15 then the next from 00 goes at more of an angle to 45,30 then 00 to 60,45 and so on until its made 7 lines. If you change the amount added to x it makes different angles, 0 and 0 makes a single line



I just want some way to take some series of ints or int32 to make the Y component. It will be taking streams or blocks of various points of some set length
 
B

Bradley1234

okay, I thought x+= was the way C# used what C calls x+. Im not trying to modify x again, but probably was.


points[x] = new Point(yourXValue, yourYValue)

Wow, thanks it works! Now the code is

for (int x = 0; x < 200; x++)

{


points[x] = new Point((x += 0), (x += 030));


}

e.Graphics.DrawLines(pen, points);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top