SignalR Example in VB

Viewed 84

I am trying to convert the following C# code to VB:

    private readonly StockTicker _stockTicker;

    public StockTickerHub() : this(StockTicker.Instance) { }

    public StockTickerHub(StockTicker stockTicker)
    {
        _stockTicker = stockTicker;
    }

    public IEnumerable<Stock> GetAllStocks()
    {
        return _stockTicker.GetAllStocks();
    }

I pretty much got it figure out, except for this one line:

public StockTickerHub() : this(StockTicker.Instance) { }

Does anyone have an idea how to convert this line to VB?

1 Answers

I believe I figured it out. The above C# code, in VB, looks like this:

Private ReadOnly _stockTicker As StockTicker

Public Sub New()
    Me.New(StockTicker.Instance)
End Sub

Public Sub New(ByVal stockTicker As StockTicker)
    _stockTicker = stockTicker
End Sub

Public Function GetAllStocks() As IEnumerable(Of Stock)
    Return _stockTicker.GetAllStocks()
End Function
Related