0

i have an VB.NET application with few functions i need to debug (like ie. Assert in C#). Is it possible and how i do that ?

    Public Shared Function createNumberArrayList(ByVal startValue As Integer, _
                                             ByVal endValue As Integer, _
                                             Optional ByVal isBackwards As Boolean = False) As ArrayList
    Dim nArrayList As New ArrayList()
    If Not isBackwards Then
        For index As Integer = startValue To endValue
            nArrayList.Add(index)
        Next
    Else
        For index As Integer = endValue To startValue
            nArrayList.Add(index)
        Next
    End If
    Return nArrayList
End Function

Basically what i need is to enter few values and see if the function works and returns proper ArrayList.

Thanks

1
  • 1
    Ugh, don't use ArrayList in .Net 2.0 and later. Commented Nov 4, 2009 at 15:27

1 Answer 1

1

Assert is not specific to C#, it's a framework method, so it can be used in any .NET language. You can do something like this:

Diagnostics.Debug.Assert(nArrayList.Count > 0)

Edit:

I'm not sure whether Debug.Assert works in ASP.NET applications or not, I found contradictory info on the web about this... If it doesn't work, check out this CodeProject article.

Sign up to request clarification or add additional context in comments.

3 Comments

How do i check this ? I mean how do i make VS to execute Debug.Assert ? Sorry for noobness
Just add asserts in your code, then run your website in debug, and it will show a popup if an Assert fails. If it doesn't... check my edit.
It will write a message in the Output window by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.