method overloading and references

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Gustafsson

    #1

    method overloading and references

    Hi there, hmm, I've just started with C# and I'm experimenting with method
    overloading.
    It seems like it's not possible to override method using return types, only
    parameters. Is that by design, anyway around that or something? I.e. I'd
    like to have the same method return either a DataReader or a DataAdapter
    depending on the lvalue when calling it.

    And another question. If I have my method returning a value, can it return
    it by reference or does it always, always copy the object?

    Anyhow, it all boils down to the fact that my class will have methods that
    are supposed to retrieve database results for me, and I want them to be able
    to provide me both with DataAdapters (for easy integration with components)
    and DataReaders (in the case I want to use the result in a loop instead of a
    component). I want to do this as seemless and simple as possible without
    having any duplication of code, 3x as many methods or stuff like that AND
    the fact that it has to be optimal performance-wize.


Working...