Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
Heath Stewart8-Jan-04 12:46
protectorHeath Stewart8-Jan-04 12:46 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
obelisk298-Jan-04 13:01
obelisk298-Jan-04 13:01 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
Heath Stewart8-Jan-04 13:11
protectorHeath Stewart8-Jan-04 13:11 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
obelisk298-Jan-04 13:20
obelisk298-Jan-04 13:20 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
obelisk298-Jan-04 14:10
obelisk298-Jan-04 14:10 
GeneralRe: Crystal Reports and Sql Server 2000 Pin
obelisk298-Jan-04 14:30
obelisk298-Jan-04 14:30 
GeneralDynamic Casting for use in Polymorphic/overloaded methods. Pin
Scott Barr8-Jan-04 11:12
Scott Barr8-Jan-04 11:12 
GeneralRe: Dynamic Casting for use in Polymorphic/overloaded methods. Pin
Heath Stewart8-Jan-04 11:50
protectorHeath Stewart8-Jan-04 11:50 
Even though TreeViewEventArgs.Node is of Type TreeNode, the actual object is of Type QuestionNode or CatalogNode so you don't need to cast it like you're doing. For instance, even though the GetType method is inherited form Object, it will always return the Type of the actual object. I even have something similar to what you have with a massive amount of tree nodes that even have other base classes and you don't need to cast them (either using the cast operator or the as keyword). So, when you call DisplayProperties with simply e.Node, it will automatically pick the correct one because the Type is either the QuestionNode or the CatalogNode, despite the Type that TreeViewEventArgs.Node is defined as (as long as its a base class).

For example:
using System;

public class Test
{
  public static void Main()
  {
    DisplayText(new A1());
    DisplayText(new A2());
  }

  private static void DisplayText(A1 a)
  {
    Console.WriteLine("DisplayText (1): {0}", a.Text);
  }

  private static void DisplayText(A2 a)
  {
    Console.WriteLine("DisplayText (2): {0}", a.Text);
  }
}

public class A
{
  public virtual string Text
  {
    get { return "A"; }
  }
}

public class A1 : A
{
  public override string Text
  {
    get { return "A1"; }
  }
}

public class A2 : A
{
  public override string Text
  {
    get { return "A2"; }
  }
}
The output would be:
DisplayText (1): A1
DisplayText (2): A2


 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Dynamic Casting for use in Polymorphic/overloaded methods. Pin
Scott Barr9-Jan-04 4:42
Scott Barr9-Jan-04 4:42 
GeneralRe: Dynamic Casting for use in Polymorphic/overloaded methods. Pin
Heath Stewart9-Jan-04 5:15
protectorHeath Stewart9-Jan-04 5:15 
GeneralRe: Dynamic Casting for use in Polymorphic/overloaded methods. Pin
Scott Barr9-Jan-04 5:30
Scott Barr9-Jan-04 5:30 
GeneralType convertion and Unmanaged code Pin
Shahin778-Jan-04 10:48
Shahin778-Jan-04 10:48 
GeneralRe: Type convertion and Unmanaged code Pin
Heath Stewart8-Jan-04 11:39
protectorHeath Stewart8-Jan-04 11:39 
GeneralRe: Type convertion and Unmanaged code Pin
Shahin778-Jan-04 11:52
Shahin778-Jan-04 11:52 
GeneralRe: Type convertion and Unmanaged code Pin
Heath Stewart8-Jan-04 12:16
protectorHeath Stewart8-Jan-04 12:16 
GeneralRe: Type convertion and Unmanaged code Pin
Heath Stewart8-Jan-04 12:37
protectorHeath Stewart8-Jan-04 12:37 
GeneralRe: Type convertion and Unmanaged code Pin
Shahin778-Jan-04 14:15
Shahin778-Jan-04 14:15 
GeneralStartup Switch Options ... Pin
Daniel Negron8-Jan-04 10:08
Daniel Negron8-Jan-04 10:08 
GeneralRe: Startup Switch Options ... Pin
Niels Penneman8-Jan-04 10:43
Niels Penneman8-Jan-04 10:43 
GeneralRe: Startup Switch Options ... Pin
Heath Stewart8-Jan-04 11:34
protectorHeath Stewart8-Jan-04 11:34 
GeneralWriting CD/DVD Pin
Christian Graus8-Jan-04 9:37
protectorChristian Graus8-Jan-04 9:37 
GeneralRe: Writing CD/DVD Pin
Mazdak8-Jan-04 9:55
Mazdak8-Jan-04 9:55 
GeneralRe: Writing CD/DVD Pin
Christian Graus8-Jan-04 9:59
protectorChristian Graus8-Jan-04 9:59 
GeneralRe: Writing CD/DVD Pin
Kentamanos8-Jan-04 10:25
Kentamanos8-Jan-04 10:25 
GeneralRe: Writing CD/DVD Pin
Kentamanos8-Jan-04 16:51
Kentamanos8-Jan-04 16:51 

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.