Visual Basic.... Convert a binary number to a decimal number

I am on this exercise Binary in Visual Basic on Exercism

and the editor sugests this solution structure:

  • Public Class Binary

  • Public Sub New(value As String)
    
  •         Throw New NotImplementedException("You need to implement this function")
    
  • End Sub
    
  • Public Function ToDecimal() As Integer
    
  •         Throw New NotImplementedException("You need to implement this function")
    
  • End Function
    
  • End Class

The input is suposed to be a binary in string form.
fair enough.
And the conversion should be pretty straightforward with iteration over the converted integer with the help of modulo.

What I dont get is how I am supposed to use the Sub method and the toDecimal function together ?.. Should I put a member variable in the class Binary maybe or what do u suggest ?

Thanks in advance

Let’s look at the tests. Here is the first test:

Assert.Equal(New Binary("011").ToDecimal(), 3)

Now we know how the Sub and the Function are used.

Should I put a member variable in the class Binary

Yes