Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
GeneralRe: Manual Coding vs Code Generation Pin
fjdiewornncalwe16-Nov-12 8:26
professionalfjdiewornncalwe16-Nov-12 8:26 
AnswerRe: Manual Coding vs Code Generation Pin
Mycroft Holmes16-Nov-12 15:37
professionalMycroft Holmes16-Nov-12 15:37 
GeneralRe: Manual Coding vs Code Generation Pin
PIEBALDconsult21-Nov-12 17:51
mvePIEBALDconsult21-Nov-12 17:51 
GeneralRe: Manual Coding vs Code Generation Pin
Mycroft Holmes21-Nov-12 18:46
professionalMycroft Holmes21-Nov-12 18:46 
GeneralRe: Manual Coding vs Code Generation Pin
PIEBALDconsult22-Nov-12 9:51
mvePIEBALDconsult22-Nov-12 9:51 
AnswerRe: Manual Coding vs Code Generation Pin
PIEBALDconsult21-Nov-12 4:00
mvePIEBALDconsult21-Nov-12 4:00 
QuestionDesign Question Pin
PozzaVecia15-Nov-12 17:31
PozzaVecia15-Nov-12 17:31 
AnswerRe: Design Question Pin
DaveyM6915-Nov-12 19:31
professionalDaveyM6915-Nov-12 19:31 
You should only use a base class where you want the exact same implementation in all derived classes.

A an interface is a contract (no implementation unlike an abstract class) I don't really see the problem. This works just fine:
C#
public interface I1
{
    void A();
    void B();
}
public interface I2
{
    void A();
    void B();
    void C();
    void D();
}
public class ClassA : I1, I2
{
    public void A()
    { }
    public void B()
    { }
    public void C()
    { }
    public void D()
    { }
}

If you want differing implementations of A and B depending on whether usin I1 or I2 then use explicit declaration:
C#
public class ClassA2 : I1, I2
{
    void I1.A()
    { }
    void I2.A()
    { }
    void I1.B()
    { }
    void I2.B()
    { }
    public void C()
    { }
    public void D()
    { }
}

You will now need to cast the instance to either I1 or I2 to have access to methods A or B, but you can mix it up and provide the default implementation:
C#
public class ClassA2 : I1, I2
{
    public void A()
    {
        (this as I1).A();
    }
    public void B()
    {
        (this as I1).B();
    }
    void I1.A()
    { }
    void I2.A()
    { }
    void I1.B()
    { }
    void I2.B()
    { }
    public void C()
    { }
    public void D()
    { }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



GeneralRe: Design Question Pin
PozzaVecia15-Nov-12 20:11
PozzaVecia15-Nov-12 20:11 
AnswerRe: Design Question Pin
Rahul Rajat Singh15-Nov-12 21:43
professionalRahul Rajat Singh15-Nov-12 21:43 
GeneralRe: Design Question Pin
PozzaVecia15-Nov-12 23:14
PozzaVecia15-Nov-12 23:14 
AnswerRe: Design Question Pin
Rahul Rajat Singh15-Nov-12 23:22
professionalRahul Rajat Singh15-Nov-12 23:22 
AnswerRe: Design Question PinPopular
BobJanova15-Nov-12 23:12
BobJanova15-Nov-12 23:12 
GeneralRe: Design Question Pin
PozzaVecia15-Nov-12 23:16
PozzaVecia15-Nov-12 23:16 
GeneralRe: Design Question Pin
Rahul Rajat Singh15-Nov-12 23:35
professionalRahul Rajat Singh15-Nov-12 23:35 
GeneralRe: Design Question Pin
BobJanova16-Nov-12 0:09
BobJanova16-Nov-12 0:09 
AnswerRe: Design Question Pin
SledgeHammer0116-Nov-12 9:53
SledgeHammer0116-Nov-12 9:53 
GeneralRe: Design Question Pin
PozzaVecia16-Nov-12 10:06
PozzaVecia16-Nov-12 10:06 
AnswerRe: Design Question Pin
Clifford Nelson16-Nov-12 9:53
Clifford Nelson16-Nov-12 9:53 
QuestionBackground worker thread Pin
MAW3015-Nov-12 14:54
MAW3015-Nov-12 14:54 
AnswerRe: Background worker thread Pin
DaveyM6915-Nov-12 18:51
professionalDaveyM6915-Nov-12 18:51 
QuestionArray, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 6:29
KKW_acd15-Nov-12 6:29 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 6:55
professionalDaveyM6915-Nov-12 6:55 
GeneralRe: Array, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 9:03
KKW_acd15-Nov-12 9:03 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 19:02
professionalDaveyM6915-Nov-12 19:02 

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.