Re: Generic filehandler method



The subtlety is that using this method the filetype is specified by the programmer that is coding the caller operation, and I would imagine there is some way to open a file as a type...is that not the case?

Thanks,
Ron



<mrshrinkray@xxxxxxxxxxxxxx> wrote in message news:46c02ac3-6e52-4d91-ad4b-02477383d635@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 15 May, 16:15, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx> wrote:
On Thu, 15 May 2008 06:23:27 -0700, Ron <rs_herh...@xxxxxxxxx> wrote:
> I am trying to build a generic static method that will return a
> specified type from a method. My problem is that I need to return say
> an image from the method...and I'm having trouble understanding how to
> do this.

It is not clear why you want this method to be generic. Whatever type you
supply for T, it _must_ be valid for the type of data you expect to
extract from the file. That means that in advance, you need to know what
type you expect. That means that there's no need for a generic method to
read the file. Just use existing type-specific i/o mechanisms.

Pete

You would need to create your own wrapper classes around each type of
file (ImageLoader,TextFileLoader,BinaryFileLoad) which as pete said
you might as well just make a class with 4 methods to handle each one,
Image and FileStream have nothing in common besides Object so there's
no way of calling a Load method generically

.



Relevant Pages

  • Re: Generic filehandler method
    ... programmer that is coding the caller operation, and I would imagine there is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Generic filehandler method
    ... programmer that is coding the caller operation, and I would imagine there is ... But how would your static method know which method to call on the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Generic filehandler method
    ... the programmer that is coding the caller operation, ... imagine there is some way to open a file as a type...is that not the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: grown out of coding
    ... The analyst got to talk to the users and managers and have enough meetings to understand what was needed/required. ... They would then create the specs that the programmer would use to create the notes the coder would use to write the program. ... It's a wonderful feeling, molding little minds. ... And coding technique: you have to see it all and know it all to be able to grade it all. ...
    (comp.databases.pick)
  • Re: free source for bbs
    ... you will be so much smarter if you realize how little about ... >understanding, you lack the basics of simple coding like scoping, api ... philological nature about what is to be understood for "programmer", ...
    (comp.lang.perl.misc)