Using Graphics.DrawLine with List<Point>

  • Thread starter Thread starter Hvid Hat
  • Start date Start date
H

Hvid Hat

Hi

Is it somehow possible to call Graphics.DrawLine with List<Point>? Does it
only take Point arrays? If so, how can I (easily) convert my List<Point>
to a Point array[]
 
Is it somehow possible to call Graphics.DrawLine with List<Point>? Does
it only take Point arrays? If so, how can I (easily) convert my
List<Point> to a Point array[]?

Have you tried calling the List<>.ToArray() method?
 
Hello Peter,
Is it somehow possible to call Graphics.DrawLine with List<Point>?
Does it only take Point arrays? If so, how can I (easily) convert my
List<Point> to a Point array[]?
Have you tried calling the List<>.ToArray() method?

Hah! I'm new to generic lists so didn't expect it to be so easy. Thanks
 
Is it somehow possible to call Graphics.DrawLine with List<Point>?
Does it only take Point arrays? If so, how can I (easily) convert my
List<Point> to a Point array[]?
Have you tried calling the List<>.ToArray() method?

Hah! I'm new to generic lists so didn't expect it to be so easy. Thanks!

You're welcome.

That said, if you are surprised that they haven't added a DrawLines()
overload that takes an IList<Point>, or IEnumerable<Point> or something
like that, I wouldn't blame you. :) Seems like a silly oversight to me.
You _should_ be able to just pass a List<> instance to some version of
DrawLines(), rather than having to convert to an array.

Pete
 
Hi,

Peter Duniho said:
Is it somehow possible to call Graphics.DrawLine with List<Point>?
Does it only take Point arrays? If so, how can I (easily) convert my
List<Point> to a Point array[]?

Have you tried calling the List<>.ToArray() method?

Hah! I'm new to generic lists so didn't expect it to be so easy. Thanks!

You're welcome.

That said, if you are surprised that they haven't added a DrawLines()
overload that takes an IList<Point>, or IEnumerable<Point> or something
like that, I wouldn't blame you. :) Seems like a silly oversight to me.
You _should_ be able to just pass a List<> instance to some version of
DrawLines(), rather than having to convert to an array.

I do not think this will every happen :(.
Cause how many methods there are in the framework that expect an Array , all
of those methods would be candidates to get a overload with List<T> , as
long as you can convert a List<> to Array it's good enough.
 
I do not think this will every happen :(.
Cause how many methods there are in the framework that expect an Array ,
all of those methods would be candidates to get a overload with List<T>
, as long as you can convert a List<> to Array it's good enough.

Well, except for the fact that it could in fact be a performance burden.

You may be right that it's too sweeping a change for Microsoft to feel
it's worth doing. But they _do_ have a variety of other things that they
do that require sweeping changes. If anything, that's one of the things a
company with their resources can be very good at. :)

Pete
 
Back
Top