For some background, I’m trying to properly learn C# because I keep finding myself dancing around it recently. I’m trying to use PowerShell to help me learn – specifically, the Get-Member cmdlet is very helpful so that I don’t have to keep flipping back and forth to MSDN.
All I’m trying to do is see available members. For the most part, I can just create a new object and then use Get-Member on it. But sometimes creating a new object doesn’t quite work.
WORKS:
$WindowsFormObject = [System.Windows.Forms.Form]::new() $WindowsFormObject | Get-Member $DialogResultObject = [System.Windows.Forms.DialogResult]::new() $DialogResultObject | Get-Member
DOESN’T WORK:
$CommonDialogObject = [System.Windows.Forms.CommonDialog]::new() Instances of abstract classes cannot be created. At line:1 char:1 + $CommonDialogObject = [System.Windows.Forms.CommonDialog]::new() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException
Maybe this issue is specific to abstract classes (still trying to wrap my head around this concept), but there’s gotta be a way to explore their members in PowerShell.
(For additional background, I’m looking specifically for the ShowDialog method under the System.Windows.Forms.CommonDialog Class, and my hunch is that since that Class is abstract, it won’t actually be there and actually exists under another Class…but I won’t know for sure until I can explore System.Windows.Forms.CommonDialog)
submitted by /u/fourierswager
[link] [comments]
The post How to use Get-Member (or functionally equivalent way of returning members) without creating an object beforehand? appeared first on How to Code .NET.