Click here to Skip to main content
15,895,462 members
Home / Discussions / C#
   

C#

 
QuestionWhat is the fastest and Efficient way? Pin
pubududilena9-Apr-06 17:43
pubududilena9-Apr-06 17:43 
AnswerRe: What is the fastest and Efficient way? Pin
Guffa9-Apr-06 19:05
Guffa9-Apr-06 19:05 
AnswerRe: What is the fastest and Efficient way? Pin
Robert Rohde9-Apr-06 22:01
Robert Rohde9-Apr-06 22:01 
QuestionHOW TO Call the Save Method of an MDI Child Form from the MDI Form Toolbar Menu Pin
Old Gun9-Apr-06 17:03
Old Gun9-Apr-06 17:03 
AnswerRe: HOW TO Call the Save Method of an MDI Child Form from the MDI Form Toolbar Menu Pin
CWIZO9-Apr-06 21:01
CWIZO9-Apr-06 21:01 
QuestionDataGrid's Style (C# Windows Form) Pin
yagang9-Apr-06 16:42
yagang9-Apr-06 16:42 
AnswerRe: DataGrid's Style (C# Windows Form) Pin
yagang10-Apr-06 16:21
yagang10-Apr-06 16:21 
QuestionMethod Overloading Troubles Pin
Skoder9-Apr-06 16:35
Skoder9-Apr-06 16:35 
Hey,

i want to do some overloading but i cannot find out how to get the object type to be right.

The problem is the following.

I have a Base class called Animals, and then i have a couple of sub classes which inherit from the Animal class (etc. Dog, Cat and soo on).

I Create my Dog and Cat objects and add them to an ArrayList.
For controlling the ArrayList i have a couple of Methods, one of them is GetAnimal();, which will return a object from the ArrayList. But as it is different what type of objects which is returned it seems that i have to return object of type Animal (the object casted).


I have a class which computes some movement and stuff.
In that class i want to Get an object (GetAnimal()) and call a method, like this.

public void Compute() {
Move(GetAnimal());
}

and then i have Move Methods for every Animal

public void Move(Dog dog) { doSomething }
public void Move(Cat cat) { doSomething }


But my problem is that when i make the GetAnimal() call i get the object as Animal and not as the Correct type needed for overloading. Soo it complains about there is no correct method for overloading.


What am i missing / doing wrong ?
What should i do to get the object as the correct type which i can use when calling the overload methods


I could of course place the methods on the objects and make it abstract instead, but it isnt reall what i want.


Hope someone can help me with this.


Best regards

Martin Confused | :confused:
AnswerRe: Method Overloading Troubles Pin
S. Senthil Kumar9-Apr-06 18:15
S. Senthil Kumar9-Apr-06 18:15 
GeneralRe: Method Overloading Troubles Pin
Skoder11-Apr-06 16:15
Skoder11-Apr-06 16:15 
QuestionWant code fragment to move line around on Form Pin
...---...9-Apr-06 11:01
...---...9-Apr-06 11:01 
AnswerRe: Want code fragment to move line around on Form Pin
Guffa9-Apr-06 11:09
Guffa9-Apr-06 11:09 
GeneralRe: Want code fragment to move line around on Form Pin
...---...9-Apr-06 13:22
...---...9-Apr-06 13:22 
AnswerRe: Want code fragment to move line around on Form Pin
Guffa9-Apr-06 19:06
Guffa9-Apr-06 19:06 
QuestionRepeater XmlNodeList Question Pin
eggie59-Apr-06 9:58
eggie59-Apr-06 9:58 
QuestionEvent of starting applications Pin
Sergey Gorchichko9-Apr-06 8:26
Sergey Gorchichko9-Apr-06 8:26 
QuestionGetPixel from Graphics object Pin
Fouad_kayali9-Apr-06 6:32
Fouad_kayali9-Apr-06 6:32 
AnswerRe: GetPixel from Graphics object Pin
Jakob Farian Krarup9-Apr-06 8:15
Jakob Farian Krarup9-Apr-06 8:15 
GeneralRe: GetPixel from Graphics object Pin
Leyu9-Apr-06 9:32
Leyu9-Apr-06 9:32 
AnswerRe: GetPixel from Graphics object Pin
Robert Rohde9-Apr-06 22:56
Robert Rohde9-Apr-06 22:56 
QuestionHelp Code Pin
nwr_mn9-Apr-06 6:16
nwr_mn9-Apr-06 6:16 
AnswerRe: Help Code Pin
User 66589-Apr-06 7:21
User 66589-Apr-06 7:21 
QuestionHelp me on Steganography Pin
nwr_mn9-Apr-06 6:13
nwr_mn9-Apr-06 6:13 
AnswerRe: Help me on Steganography Pin
Joshua Quick9-Apr-06 11:37
Joshua Quick9-Apr-06 11:37 
QuestionHelp me on Steganography Pin
nwr_mn9-Apr-06 6:03
nwr_mn9-Apr-06 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.