Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List .NET objects inside an object

Tags:

c#

powershell

I don't know how can I access objects inside an object. Everything I read is about the Get-Member option, but that is in order to listing the methods/property, not the classes inside a class, it seems like it is taken for granted or you should know it or something.

I want to get the classes inside System.Net, or whatever class I want to be listed:

  • WebRequest
  • Sockets
  • WebClient

I already know that I can be shown the methods inside with

[System.Net.WebRequest] | gm -Static

or without -Static for the general methods.

like image 594
aDoN Avatar asked Mar 12 '26 09:03

aDoN


1 Answers

Give this a try

[System.AppDomain]::CurrentDomain.GetAssemblies() | 
    % { $_.GetTypes() } |
    ? { $_.IsPublic -and $_.Namespace -ne $null -and $_.Namespace.StartsWith("System.Net")    

Of course you can alter the filtering according to your needs and add sorting if necessary

like image 142
DAXaholic Avatar answered Mar 14 '26 22:03

DAXaholic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!