| |

VerySource

 Forgot password?
 Register
Search
View: 826|Reply: 8

How to convert System.Drawing.Point to System.Drawing.Point []? ?

[Copy link]

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-11 18:00:01
| Show all posts |Read mode
I don't know if I ask this right
I
private ArrayList array = new ArrayList ();
private Point [] p;
. . .

p = new Point (e.X, e.Y);
An error occurs saying that it is not possible to implicitly convert System.Drawing.Point to System.Drawing.Point []
But I must use arrays
Do you guys know how to solve this problem?
Thank you
Reply

Use magic Report

0

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-17 13:18:01
| Show all posts
Since you stated that Point [] is a set (array), and your current p (eX, eY) is one of the elements, of course, you cannot assign this value. If you want to use it, you can try p [0] = new Point (eX, eY);

I don't know if I'm right. Under the guidance of a master, let me help you.
Reply

Use magic Report

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-17 16:36:01
| Show all posts
I know That's the way I don't know what to do I want to put the points passed by the mouse in an array
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-19 11:45:02
| Show all posts
Does the host mean to record the points passed by the mouse into the ArrayList
Then directly array.Add (new Point (e.X, e.Y)); OK
Don't know what it means to define a Point []?
Reply

Use magic Report

0

Threads

12

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-20 09:00:02
| Show all posts
Haha, too much
Reply

Use magic Report

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-27 10:45:01
| Show all posts
Because I do n’t just need to record these points, I need to filter these points, save them to the database, and use a for statement to make a loop. So I need to use array
I wonder if everyone has a better way
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-27 13:54:01
| Show all posts
point p = new point ();
array.add (p);
The array of ArrayList is stored as a set of objects, so using its member functions can insert different objects into the array. There is a boxing process in the middle.
When reading, p = (point) array [0];
There is a process of unboxing
You can use generic List <point> list = new List <point> ();
list.add (p);
point p2 = list [0];
No explicit conversion
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-27 15:18:01
| Show all posts
Just use private ArrayList array = new ArrayList ();
Add points to the array and add array.Add (new Point (e.X, e.Y));
array is equivalent to an array, and it can also loop
Reply

Use magic Report

2

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-27 22:45:02
| Show all posts
You can pull it, thank you for your help
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list