Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Using Graphics.DrawLine with List<Point>

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hvid Hat - 14 Feb 2008 22:00 GMT
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[]
Peter Duniho - 14 Feb 2008 22:22 GMT
> 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?
Hvid Hat - 14 Feb 2008 22:43 GMT
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
Peter Duniho - 14 Feb 2008 22:58 GMT
>>> 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
[quoted text clipped - 3 lines]
>
> 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
Ignacio Machin ( .NET/ C# MVP ) - 15 Feb 2008 12:56 GMT
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
[quoted text clipped - 11 lines]
> 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.
Peter Duniho - 15 Feb 2008 23:35 GMT
>> That said, if you are surprised that they haven't added a DrawLines()  
>> overload that takes an IList<Point>, or IEnumerable<Point> or something  
[quoted text clipped - 6 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.