Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
QuestionNeed advice on light weight database-like design Pin
DeepToot17-Aug-08 13:37
DeepToot17-Aug-08 13:37 
AnswerRe: Need advice on light weight database-like design Pin
N a v a n e e t h17-Aug-08 19:40
N a v a n e e t h17-Aug-08 19:40 
QuestionCheck if form is open? Pin
Arcdigital17-Aug-08 11:37
Arcdigital17-Aug-08 11:37 
AnswerRe: Check if form is open? Pin
lisan_al_ghaib17-Aug-08 12:37
lisan_al_ghaib17-Aug-08 12:37 
AnswerRe: Check if form is open? another way Pin
Natza Mitzi17-Aug-08 13:45
Natza Mitzi17-Aug-08 13:45 
QuestionCasting from a Base to Derived Class Pin
Jammer17-Aug-08 8:21
Jammer17-Aug-08 8:21 
AnswerRe: Casting from a Base to Derived Class Pin
Pete O'Hanlon17-Aug-08 8:34
mvePete O'Hanlon17-Aug-08 8:34 
AnswerRe: Casting from a Base to Derived Class Pin
Wendelius17-Aug-08 8:37
mentorWendelius17-Aug-08 8:37 
Hi,

casting from derived class to base class is acceptable but not vice versa if the base class doesn't have all of the functionality that is defined in derived class (which is the usual situation). Consider following
class BaseClass {
   public int value1;
}
class DerivedClass : BaseClass {
   public int value2;
}

static void Main() {
   DerivedClass dc = new DerivedClass();
   BaseClass bc = dc; //works

   BaseClass bc2 = new BaseClass();
   DerivedClass dc2 = (DerivedClass)bc2; //fails at runtime because BaseClass doesn't have all the functionality of the DerivedClass
}

Based on this your second example should be ok.

Mika
GeneralRe: Casting from a Base to Derived Class Pin
Jammer17-Aug-08 9:25
Jammer17-Aug-08 9:25 
GeneralRe: Casting from a Base to Derived Class Pin
Jammer17-Aug-08 9:30
Jammer17-Aug-08 9:30 
GeneralRe: Casting from a Base to Derived Class Pin
Wendelius17-Aug-08 9:52
mentorWendelius17-Aug-08 9:52 
GeneralRe: Casting from a Base to Derived Class Pin
Jammer17-Aug-08 10:15
Jammer17-Aug-08 10:15 
GeneralRe: Casting from a Base to Derived Class Pin
Wendelius17-Aug-08 10:17
mentorWendelius17-Aug-08 10:17 
QuestionHow to Bind combobox to Datatable coloums in connected mode??(Windows application) Pin
rahul2117-Aug-08 6:00
rahul2117-Aug-08 6:00 
AnswerRe: How to Bind combobox to Datatable coloums in connected mode??(Windows application) Pin
Manas Bhardwaj17-Aug-08 6:40
professionalManas Bhardwaj17-Aug-08 6:40 
AnswerRe: How to Bind combobox to Datatable coloums in connected mode??(Windows application) Pin
N a v a n e e t h17-Aug-08 7:04
N a v a n e e t h17-Aug-08 7:04 
QuestionSendKeys and ^ Pin
Dominik Reichl17-Aug-08 2:16
Dominik Reichl17-Aug-08 2:16 
AnswerRe: SendKeys and ^ Pin
Wendelius17-Aug-08 3:04
mentorWendelius17-Aug-08 3:04 
QuestionRe: SendKeys and ^ Pin
Dominik Reichl17-Aug-08 3:59
Dominik Reichl17-Aug-08 3:59 
AnswerRe: SendKeys and ^ Pin
Wendelius17-Aug-08 4:31
mentorWendelius17-Aug-08 4:31 
QuestionImplementing IDisposable in Sealed class Pin
Blumen17-Aug-08 0:48
Blumen17-Aug-08 0:48 
AnswerRe: Implementing IDisposable in Sealed class Pin
Colin Angus Mackay17-Aug-08 0:59
Colin Angus Mackay17-Aug-08 0:59 
GeneralRe: Implementing IDisposable in Sealed class Pin
Blumen17-Aug-08 1:30
Blumen17-Aug-08 1:30 
GeneralRe: Implementing IDisposable in Sealed class Pin
Colin Angus Mackay17-Aug-08 2:03
Colin Angus Mackay17-Aug-08 2:03 
GeneralRe: Implementing IDisposable in Sealed class [modified] Pin
Blumen17-Aug-08 2:59
Blumen17-Aug-08 2:59 

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.