title: trying to create a custom cmdlet, which takes [ref] as a parameter
body: <pre><code>//powershell code
  
  $quiotent = divRemainderQuiotent ($a) ($b) ([ref] $remainder) # I need to pass this $remainder as reference
  </code></pre>
  
  <p>For that I need to pass it as PSReference</p>
  
  <pre><code>//csharp code 
  
  private PSReference remainder= null;
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly"),
         Parameter(
             Position = 2,
             Mandatory = true,
             ValueFromPipeline = true)]
          [ValidateNotNullOrEmpty]
          public PSReference Remainder // if I don’t use this and use a value type and later change it to ref (inside C#) the result won’t bubble up, which I think is bad.
          {
              set { remainder = value; }
          }
  </code></pre>
  
  <p>But now the problem becomes, the function that takes this parameter as ref integer.</p>
  
  <pre><code>  protected override void ProcessRecord()
          {
              //main method, this is executed when cmdlet is run
              int r = remainder ; //this is the problem I cannot convert PSReference to other object type (integer here).
              int q = _csharpDivideRemainderQuiotent(a,b, ref r); // if I change this function to take PSReference type, I will have to make changes down the line for every function.
              WriteObject(q);
          } // method ProcessRecord
  </code></pre>