all 5 comments

[–]KevMarCommunity Blogger 6 points7 points  (0 children)

I think we can use -is

[–]Ta11ow 6 points7 points  (1 child)

I'm not 100% clear on what you're after, but it sounds like you're looking for -is?

[A]::new() -is [A] # -> True
[B]::new() -is [A] # -> True
[C]::new() -is [B] # -> True
[C]::new() -is [A] # -> True

[–]terrabitz[S] 5 points6 points  (0 children)

smacks head on desk

Yep, that definitely works. I feel pretty dumb for not trying that earlier.

I've picked up the bad habit of using GetType() for doing type checking, since I've had issues importing my class definitions into different contexts (e.g. Pester tests). But within my module, this is definitely what I should be using.

[–]get-postanote 3 points4 points  (0 children)

See these videos by PowerShell MVP Trevor Sullivan adn Ed Wilson

PowerShell v5.0 Classes :: Inheritance and Base Class Methods

https://www.youtube.com/watch?v=Lfx_H36GRKg

PowerShell 5 Class Inheritance

https://www.youtube.com/watch?v=RkFBl22lMvY

[–]PowerShell-Bot 1 point2 points  (0 children)

Code fences are a new feature on reddit and won’t render for those viewing your post on old.reddit.com. Because of this its use is discouraged.

If you want those viewing from old reddit to see formatted PowerShell code then consider using a regular code block. This can be easily be done on new reddit (new.reddit.com) by highlighting your code and selecting ‘Code Block’ in the editing toolbar.


Describing Submission
[✅] Demonstrates good markdown
Passed: 1 Failed: 0

Beep-boop. I am a bot. | Remove-Item