Results 1 to 2 of 2

Thread: Typecast or not to typecast...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Typecast or not to typecast...

    I had an interesting encounter with a typecast problem today.

    I wanted to pass a DirectoryInfo[i].name property in a function.

    But it refused to work, so I wrote the function call like

    function(string blabla, (string)DirectoryInfo[i].name);

    and declared it as a string in the function header... and it worked. But was this the right way to do it?

    How should I have written it in the function, cause right now I wrote

    static public myFunc(string blabla, string directoryname)
    {
    tytrur;
    }


    info, thoughts or comments??? I really don't like to make typecasts like this...

    best regards
    Henrik

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Yes it can be done that way, but you can also do this

    Code:
    function(string blabla, DirectoryInfo[i].name.ToString());
    Dont gain the world and lose your soul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width