Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# check if type implements interface

typeof(IMyInterface).IsAssignableFrom(typeof(MyType))
  // or
typeof(MyType).GetInterfaces().Contains(typeof(IMyInterface))
  // or for a generic interface, it’s a bit different:
typeof(MyType).GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMyInterface<>)
Comment

PREVIOUS NEXT
Code Example
Csharp :: how do i convert to base64 c# 
Csharp :: c# get user directory 
Csharp :: Changing datagridview cell color dynamically 
Csharp :: unity how to refrsh scene 
Csharp :: check dotnet version command line 
Csharp :: how to edit postprocessing through script 
Csharp :: c# save bytes array to file 
Csharp :: csgo throw last grenade bind 
Csharp :: c# Escape sequence 
Csharp :: unity exit application 
Csharp :: c# check if a directory exists 
Csharp :: c# player movement 
Csharp :: c# count files in directory and subdirectories 
Csharp :: c# windows grab screenshot 
Csharp :: left moust click unity 
Csharp :: randomize through array in C# 
Csharp :: c# get all bytes of a file 
Csharp :: core Request.CreateResponse 
Csharp :: get request url in asp.net core 
Csharp :: easily start admin process from service c# 
Csharp :: unity raycast all layers except one 
Csharp :: unity disable cursor 
Csharp :: unity destroy object when out of screen 
Csharp :: unity main texture not working 
Csharp :: c# System.Resources.MissingManifestResourceException error 
Csharp :: system.text.json DeserializeAsync when to use 
Csharp :: c# int to byte array 
Csharp :: c# string to char 
Csharp :: c# write text before user input 
Csharp :: wpf rounded image 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =