sharpdevelop - Cannot implicitly convert type 'string' to 'string[]', when converting CType to C# -
i doing automatic conversion of code written in vb.net c# sharpdevelop's v4.4 converting tool. vb.net code drag/drop on form this:
private sub me_dragdrop(byval sender object, byval e system.windows.forms.drageventargs) handles me.dragdrop if e.data.getdatapresent(dataformats.filedrop) dim myfiles() string = ctype(e.data.getdata(dataformats.filedrop), string()) if myfiles.length > 0 then...
converted c# code such:
private void me_dragdrop(object sender, system.windows.forms.drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { string[] myfiles = convert.tostring(e.data.getdata(dataformats.filedrop)); if (myfiles.length > 0) {...
in c# ide line convert.tostring(e.data.getdata(dataformats.filedrop)) underlined red , error cannot implicitly convert type 'string' 'string[] reported.
telerik tool converting net languages makes here same translation.
what point here, how working in c# , better: how write vb.net code translated correctly?
you want...
string[] myfiles = (string[])e.data.getdata(dataformats.filedrop);
..actually... going coding standards...
string[] myfiles = (string[])e.data.getdata(dataformats.filedrop);
as why didn't convert properly, it's ask support tool vendor. can suggest try casting in vb.net using directcast instead of ctype see if better job of converting code.
Comments
Post a Comment