Click here to Skip to main content
15,867,921 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a colletion of properties in a C# class Pin
bnath0013-Jan-13 5:59
bnath0013-Jan-13 5:59 
GeneralRe: How to create a colletion of properties in a C# class Pin
OriginalGriff3-Jan-13 8:24
mveOriginalGriff3-Jan-13 8:24 
GeneralIf I use Dictionary, I am not able to serialize it Pin
bnath0013-Jan-13 9:08
bnath0013-Jan-13 9:08 
GeneralRe: If I use Dictionary, I am not able to serialize it Pin
OriginalGriff3-Jan-13 9:50
mveOriginalGriff3-Jan-13 9:50 
GeneralRe: If I use Dictionary, I am not able to serialize it Pin
bnath0013-Jan-13 10:44
bnath0013-Jan-13 10:44 
QuestionCA2214 Do not call overridable methods in constructors Pin
DaveyM692-Jan-13 12:35
professionalDaveyM692-Jan-13 12:35 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
PIEBALDconsult2-Jan-13 13:38
mvePIEBALDconsult2-Jan-13 13:38 
AnswerRe: CA2214 Do not call overridable methods in constructors Pin
Alan N2-Jan-13 14:28
Alan N2-Jan-13 14:28 
This is one of those 'well it depends' rules. Think about the order in which chained constructors are called. The first thing derived class B's constructor does is call base class A's constructor.

If A's constructor now calls a virtual instance method defined in class B, it is accessing a partially initialised class. Remember that B's constructor has not run yet and all of B's instance data will be in an unknown state but it will be perfectly safe to call the instance method as long as it does not rely on instance data.

Examples of situations where this technique is used can be seen in the System.Windows.Forms class. Here you will find the protected bool ShowWithoutActivation property which is called internally and in the base class returns the constant value false. Overriding to return constant true changes the behaviour of a derived class. Similarly the property CreateParams can also be overridden to supply non default parameters to the base class.

So my feeling is it's OK to ignore CA2214 as long as you treat the overridden method or property as if it were static and don't do anything naughty.

Alan.
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM692-Jan-13 22:33
professionalDaveyM692-Jan-13 22:33 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
Pete O'Hanlon2-Jan-13 22:53
subeditorPete O'Hanlon2-Jan-13 22:53 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
BobJanova3-Jan-13 1:36
BobJanova3-Jan-13 1:36 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
Pete O'Hanlon3-Jan-13 1:42
subeditorPete O'Hanlon3-Jan-13 1:42 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM693-Jan-13 3:22
professionalDaveyM693-Jan-13 3:22 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM693-Jan-13 12:10
professionalDaveyM693-Jan-13 12:10 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
jschell3-Jan-13 8:16
jschell3-Jan-13 8:16 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM693-Jan-13 11:36
professionalDaveyM693-Jan-13 11:36 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
Bernhard Hiller3-Jan-13 22:48
Bernhard Hiller3-Jan-13 22:48 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
jschell4-Jan-13 13:08
jschell4-Jan-13 13:08 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM695-Jan-13 3:00
professionalDaveyM695-Jan-13 3:00 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
jschell6-Jan-13 4:42
jschell6-Jan-13 4:42 
AnswerRe: CA2214 Do not call overridable methods in constructors Pin
BobJanova3-Jan-13 1:41
BobJanova3-Jan-13 1:41 
GeneralRe: CA2214 Do not call overridable methods in constructors Pin
DaveyM693-Jan-13 12:29
professionalDaveyM693-Jan-13 12:29 
QuestionBind listview row color to active index Pin
bornefalk2-Jan-13 9:50
bornefalk2-Jan-13 9:50 
QuestionUI Automation and MMC Pin
RonNYC22-Jan-13 5:57
RonNYC22-Jan-13 5:57 
Questionmove a newfolder form a system on other system on the network by c# Pin
a2bj1-Jan-13 23:39
a2bj1-Jan-13 23:39 

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.