Click here to Skip to main content
15,888,280 members
Home / Discussions / C#
   

C#

 
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 
The reason this is a warning is because you can get yourself into some really nasty messes by doing this, if you don't understand it. The virtual method that you override in the subclasses is run with an incompletely initialised object – in particular its own constructor has not yet run so you don't have access to any instance variables, even those set in a constructor or in field initialisers (as they're compiled into the constructor too).

You've obviously simplified your example a lot and in this case you can provide a protected setter for Id and create the specific data objects in the subclass constructors. I'd say that's a better approach if it's possible.
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 
AnswerRe: move a newfolder form a system on other system on the network by c# Pin
Jibesh1-Jan-13 23:46
professionalJibesh1-Jan-13 23:46 
AnswerRe: move a newfolder form a system on other system on the network by c# Pin
Simon_Whale2-Jan-13 3:02
Simon_Whale2-Jan-13 3:02 
Questiondata Set Not Coming In GridView Pin
GugliMugli1-Jan-13 17:50
GugliMugli1-Jan-13 17:50 
AnswerRe: data Set Not Coming In GridView Pin
Jibesh1-Jan-13 21:25
professionalJibesh1-Jan-13 21:25 
GeneralRe: data Set Not Coming In GridView Pin
GugliMugli1-Jan-13 23:35
GugliMugli1-Jan-13 23:35 
GeneralRe: data Set Not Coming In GridView Pin
Jibesh1-Jan-13 23:36
professionalJibesh1-Jan-13 23:36 
GeneralRe: data Set Not Coming In GridView Pin
GugliMugli1-Jan-13 23:40
GugliMugli1-Jan-13 23:40 
GeneralRe: data Set Not Coming In GridView Pin
Jibesh1-Jan-13 23:42
professionalJibesh1-Jan-13 23:42 
GeneralRe: data Set Not Coming In GridView Pin
GugliMugli1-Jan-13 23:57
GugliMugli1-Jan-13 23:57 
GeneralRe: data Set Not Coming In GridView Pin
Jibesh2-Jan-13 0:02
professionalJibesh2-Jan-13 0:02 
GeneralRe: data Set Not Coming In GridView Pin
GugliMugli2-Jan-13 1:27
GugliMugli2-Jan-13 1:27 
GeneralRe: data Set Not Coming In GridView Pin
Jibesh2-Jan-13 1:29
professionalJibesh2-Jan-13 1:29 
AnswerRe: data Set Not Coming In GridView Pin
Richard MacCutchan2-Jan-13 1:47
mveRichard MacCutchan2-Jan-13 1:47 

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.