0

In the immediate window of Visual Studio, with C#, after writing the word port, I am getting this one:

port
{Renci.SshNet.ForwardedPortRemote}
    BoundHost: "123.45.67.89"
    BoundHostAddress: {123.45.67.89}
    BoundPort: 4222
    Host: "123.45.67.89"
    HostAddress: {123.45.67.89}
    IsStarted: true
    Port: 4222

Question - how to display the value of BoundPort on the console? I have tried this:

Console.WriteLine($"Trying port {port}.");

But then of course, I am getting only the class name.

Console.WriteLine($"Trying port {port["BoundPort"]}.");

does not compile.

Vityata
  • 42,633
  • 8
  • 55
  • 100
  • Error CS0103: The name 'port' does not exist in the current context is displayed in my environment. Did you use any nugets, what is the item type, and do you have detailed code? – Jiale Xue - MSFT Apr 20 '22 at 07:44
  • @JialeXue-MSFT - the item type is as given in the immediate window output - `Renci.SshNet.ForwardedPortRemote`. No detailed code. – Vityata Apr 20 '22 at 07:47
  • `Console.WriteLine($"Trying port {port}.");` If you just got the class name. So does `port.BoundPort` work? – Jiale Xue - MSFT Apr 20 '22 at 08:08
  • @JialeXue-MSFT - `port.BoundPort` does not work. – Vityata Apr 20 '22 at 08:21
  • What dll or library did you use? I didn't find an item type called `Renci.SshNet.ForwardedPortRemote`. Can you use `F12` to see the definition? You need to provide [a minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) here. – Jiale Xue - MSFT Apr 20 '22 at 08:28

0 Answers0