Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ListBox - Unable to cast object of type 'System.DateTime' to type 'System.String'.

$
0
0

Hello:

I have a listbox with DateTime objects.

I then have a method that I need to call and pass in the items from the listbox:

public bool copyFiles(List<string> datesProcess)

I attempt to call the method passing in the listbox:

if (obj.copyFiles(lstProcessDate.Items.Cast<string>().ToList()))
            { ...

I then receive the error:

Unable to cast object of type 'System.DateTime' to type 'System.String'.

How can I cast the DateTime items from the listbox to pass them in correctly as a list of string objects?

Thanks Before Hand


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>