Click here to Skip to main content
15,927,344 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.Security.Cryptography.ProtectedData Does Not Exist Pin
Sathesh Sakthivel12-Dec-07 9:01
Sathesh Sakthivel12-Dec-07 9:01 
QuestionPrinting an image in the middle of a page Pin
devzav12-Dec-07 6:40
devzav12-Dec-07 6:40 
GeneralRe: Printing an image in the middle of a page Pin
Paul Conrad23-Dec-07 9:57
professionalPaul Conrad23-Dec-07 9:57 
GeneralRe: Printing an image in the middle of a page Pin
devzav23-Dec-07 10:35
devzav23-Dec-07 10:35 
QuestionUsing Interfaces to force the creation of methods Pin
Clive D. Pottinger12-Dec-07 6:21
Clive D. Pottinger12-Dec-07 6:21 
GeneralRe: Using Interfaces to force the creation of methods Pin
Skippums12-Dec-07 6:44
Skippums12-Dec-07 6:44 
GeneralRe: Using Interfaces to force the creation of methods Pin
Clive D. Pottinger12-Dec-07 7:06
Clive D. Pottinger12-Dec-07 7:06 
GeneralRe: Using Interfaces to force the creation of methods Pin
Judah Gabriel Himango12-Dec-07 9:02
sponsorJudah Gabriel Himango12-Dec-07 9:02 
What Jeff said is the right way to do it; the Dog class should be abstract, and there should be an abstract method called DoTrick on it.

Another way of doing this, if you wanted to keep the Dog class non-abstract, you could do it like this:

class Dog
{
    public virtual void DoTrick()
    {
         // Does nothing!
    }
}
Notice the virtual method - that means derived classes, such as Dobermans, can override that method and provide their own implementation:

public class Doberman
{
    public override void DoTrick()
    {
        // do a trick that only dobermans can do!
        ...
    }
} 
This will accomplish the same thing: all dogs can do a trick. However, it doesn't force derivatives to implement DoTrick; if Doberman didn't override it, DoTrick would exist but would do nothing (e.g. see the Dog.DoTrick method). If you want to force derivatives to provide a custom DoTrick method, an abstract method is the way to go, just like Jeff showed you.


Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Story of the Spoiled Child
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango


GeneralRe: Using Interfaces to force the creation of methods Pin
Pete O'Hanlon12-Dec-07 11:06
mvePete O'Hanlon12-Dec-07 11:06 
GeneralSplash Screen Shows Black before Showing Pin
Sukhjinder_K12-Dec-07 5:55
Sukhjinder_K12-Dec-07 5:55 
GeneralRe: Splash Screen Shows Black before Showing Pin
Luc Pattyn12-Dec-07 7:23
sitebuilderLuc Pattyn12-Dec-07 7:23 
GeneralRemoving base.OnPaint(e) still does not help Pin
Sukhjinder_K12-Dec-07 16:22
Sukhjinder_K12-Dec-07 16:22 
GeneralRe: Removing base.OnPaint(e) still does not help Pin
Luc Pattyn13-Dec-07 7:22
sitebuilderLuc Pattyn13-Dec-07 7:22 
GeneralBut my Image is Non-Rectangular Pin
Sukhjinder_K13-Dec-07 22:11
Sukhjinder_K13-Dec-07 22:11 
GeneralGraphicsPaths and Scrolling Pin
DahrkDaiz12-Dec-07 5:38
DahrkDaiz12-Dec-07 5:38 
GeneralRe: GraphicsPaths and Scrolling Pin
Paul Conrad23-Dec-07 9:57
professionalPaul Conrad23-Dec-07 9:57 
GeneralCell phones application using c#.net Pin
mostafa_h12-Dec-07 5:26
mostafa_h12-Dec-07 5:26 
GeneralRe: Cell phones application using c#.net Pin
Sathesh Sakthivel12-Dec-07 6:57
Sathesh Sakthivel12-Dec-07 6:57 
GeneralRe: Cell phones application using c#.net Pin
mostafa_h12-Dec-07 9:49
mostafa_h12-Dec-07 9:49 
Generalc# event log size Pin
oi12-Dec-07 5:19
oi12-Dec-07 5:19 
GeneralDynamically instantiating a type and validating interface implementation Pin
Le centriste12-Dec-07 4:49
Le centriste12-Dec-07 4:49 
GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
led mike12-Dec-07 5:11
led mike12-Dec-07 5:11 
GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
m@u12-Dec-07 5:22
m@u12-Dec-07 5:22 
GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
Le centriste12-Dec-07 5:54
Le centriste12-Dec-07 5:54 
Generaldeclaring form Pin
arkiboys12-Dec-07 4:35
arkiboys12-Dec-07 4:35 

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.