Type casting and type comparison in generic class lazarus / 62-General ---------------------------------------------------------------------- PawelO · 2021-05-30 14:49 Hello, Is it possible to compare generic type with other types? I have generic class where I need to handle some object as object of T type, but it can be any type and first it should be checked. When I use "someObject is T", or "someObject as T", i get compiler error "Class or interface expected, but got ". I figured out I can use "a := T(someObject)" to do typecasting, it works, but it doesn't check type, and wrong assignment is undetected, which later causes access violations. Is there any way to check type? Best regards, Pawel ---------------------------------------------------------------------- Warfley · 2021-05-30 15:46 Try adding a constraint to classes: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i typegeneric TFoo = class... ---------------------------------------------------------------------- PawelO · 2021-05-30 16:21 That solves problem, thanks for quick answer.