Click here to Skip to main content
15,899,314 members
Home / Discussions / C#
   

C#

 
GeneralShell execute in C# Pin
Member 445055116-Jun-04 3:24
Member 445055116-Jun-04 3:24 
GeneralRe: Shell execute in C# Pin
Colin Angus Mackay16-Jun-04 3:36
Colin Angus Mackay16-Jun-04 3:36 
GeneralRe: Shell execute in C# Pin
Member 445055116-Jun-04 5:55
Member 445055116-Jun-04 5:55 
GeneralGet type of derived class from base class Pin
joev16-Jun-04 3:06
joev16-Jun-04 3:06 
GeneralRe: Get type of derived class from base class Pin
Heath Stewart16-Jun-04 4:21
protectorHeath Stewart16-Jun-04 4:21 
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 10:39
joev16-Jun-04 10:39 
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 10:53
joev16-Jun-04 10:53 
GeneralRe: Get type of derived class from base class Pin
Heath Stewart16-Jun-04 10:58
protectorHeath Stewart16-Jun-04 10:58 
You should read a little more about polymorphism. Even if B doesn't override PrintType, this is still an instance of B.

Just modify the sample and you'll see:
using System;

public class A
{
  static void Main()
  {
    A a = new A();
    a.PrintType();
    
    a = new B();
    a.PrintType();
  }

  protected void PrintType()
  {
    Console.WriteLine(this.GetType());
  }
}

public class B : A
{
}
For statics, there is no this reference so you can't do it this way. It's this (which is implicit, so you don't need to type this) that is the correct Type.

Statics are defined on a particular Type and even if you used StackTrace you would see the static member called on the defining Type. Reflection won't help.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 11:09
joev16-Jun-04 11:09 
Generalline color of textBox or listBox Pin
Member 117814516-Jun-04 2:03
Member 117814516-Jun-04 2:03 
GeneralRe: line color of textBox or listBox Pin
LongRange.Shooter16-Jun-04 4:13
LongRange.Shooter16-Jun-04 4:13 
GeneralRe: line color of textBox or listBox Pin
Member 117814516-Jun-04 4:26
Member 117814516-Jun-04 4:26 
GeneralInterfaces in C# Pin
saud_a_k16-Jun-04 1:46
saud_a_k16-Jun-04 1:46 
GeneralRe: Interfaces in C# Pin
IamADotNetGuy16-Jun-04 3:39
IamADotNetGuy16-Jun-04 3:39 
GeneralRe: Interfaces in C# Pin
LongRange.Shooter16-Jun-04 4:27
LongRange.Shooter16-Jun-04 4:27 
GeneralRe: Interfaces in C# Pin
saud_a_k16-Jun-04 18:40
saud_a_k16-Jun-04 18:40 
GeneralRe: Interfaces in C# Pin
Stefan Troschuetz16-Jun-04 19:31
Stefan Troschuetz16-Jun-04 19:31 
GeneralRe: Interfaces in C# Pin
saud_a_k16-Jun-04 19:41
saud_a_k16-Jun-04 19:41 
GeneralRe: Interfaces in C# Pin
Stefan Troschuetz16-Jun-04 19:46
Stefan Troschuetz16-Jun-04 19:46 
GeneralRe: Interfaces in C# Pin
LongRange.Shooter17-Jun-04 3:22
LongRange.Shooter17-Jun-04 3:22 
GeneralDate Picker in DataGrid Pin
sulmun16-Jun-04 0:19
sulmun16-Jun-04 0:19 
GeneralRe: Date Picker in DataGrid Pin
Heath Stewart16-Jun-04 4:18
protectorHeath Stewart16-Jun-04 4:18 
GeneralPrintPreviewDialog? - HowTo convert string to PrintDocument! Pin
QzRz16-Jun-04 0:12
QzRz16-Jun-04 0:12 
GeneralRe: PrintPreviewDialog? - HowTo convert string to PrintDocument! Pin
exhaulted16-Jun-04 0:41
exhaulted16-Jun-04 0:41 
GeneralRe: PrintPreviewDialog? - HowTo convert string to PrintDocument! Pin
QzRz16-Jun-04 0:52
QzRz16-Jun-04 0:52 

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.