Answers for "c# check typeof"

C#
0

how to check type c#

using System;

class MainClass {
  public static void Main (string[] args) {
    
  string akuma = "Messatsu";

  Console.WriteLine(num.GetType());
  Console.WriteLine(num);
  }
}
// string
// Messatsu
Posted by: Guest on April-13-2021
0

c# typeof

string s = "Geeks"; 
Console.WriteLine(s.GetType());
Posted by: Guest on February-08-2021
1

how to check type 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);
Posted by: Guest on August-11-2021

C# Answers by Framework

Browse Popular Code Answers by Language