Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get type of object

//Exact runtime type of the current instance.
object.GetType();
Comment

how to get type of an object in c#

class Animal { } 
class Dog : Animal { }

void PrintTypes(Animal a) { 
    Console.WriteLine(a.GetType() == typeof(Animal)); // false 
    Console.WriteLine(a is Animal);                   // true 
    Console.WriteLine(a.GetType() == typeof(Dog));    // true
    Console.WriteLine(a is Dog);                      // true 
}

Dog spot = new Dog(); 
PrintTypes(spot);
Comment

c# get type of class

Type tp = value.GetType();
Comment

how to find the type of a object c#

use the "is" keyword
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to verify the scene unity 
Csharp :: convert string to int c# 
Csharp :: redirect to another controller page in asp.net core 
Csharp :: total months between two dates c# 
Csharp :: The server requested authentication method unknown to the client 
Csharp :: unity instantiate prefab rotation 
Csharp :: unity rotate direction by angle 
Csharp :: c# use hashtable check if key exists 
Csharp :: c# insert character into string at position 
Csharp :: enumerable.range contains 
Csharp :: c# save pdf to folder 
Csharp :: unity raycast 2d 
Csharp :: get out of foreach statement c# 
Csharp :: unity ui movement 
Csharp :: unity call function on animation end 
Csharp :: remove adjacent duplicate characters 
Csharp :: csharp datagridview filter column 
Csharp :: git find commits by file path 
Csharp :: ef rollback migration 
Csharp :: roman to int 
Csharp :: windows form textbox password 
Csharp :: c# add object to array 
Csharp :: single line and multiline comments in c# 
Csharp :: asp.net core mvc jsonresult example 
Csharp :: unity cancel momentum 
Csharp :: nunjucks index in loop 
Csharp :: update listbox using class c# 
Csharp :: asp.net core miniprofiler 
Csharp :: c# kill one excel process 
Csharp :: text read C# 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =