Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to use nested C# classes in PowerShell?

$
0
0

$sA=@'
  public class A {
    public string s1;
   public class B {
     public string s2;
   }
 }
'@

Add-Type-TypeDefinition$sA-IgnoreWarnings
$A=New-Object A

$A.s1='aaaaaa';Write-Host$A.s1
Write-Host (Get-Member-InputObject$A)# Nothing about B
# and this is error
$A.B.s2='cccccc';Write-Host$A.B.s2

This doesn’t work, but, I hope, shows what I want to do. How to make it working?

Thanks, Vilmos


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>