0

I created a list using a class which has different data types. It is populated as follows:

   [1/16/2015 10:30:14 PM] 241.167.2.72:5

   [1/17/2015 11:30:06 PM] 100.133.2.55:6

   [1/18/2015 12:30:33 PM] 206.140.3.10:7

Now I just want to display this in a textbox on a page. But get this:

   ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows

   ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows

   ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows

I'm using this line of code with the ToString()...but obviously it is not correct.

strSampleFlowLine = formattedDDoSSampleFlow.ToString() & vbCrLf & vbCrLf

Any Ideas?

The code (and classes) that attempts to populate the text box on the page:

    Dim ddosDetailsInfoResult As New DedicatedServerApi.DDoSDetailsInfoResult
    Dim formattedDDoSSampleFlow As New DedicatedServerApi.Formatted_DDoS_SampleFlows
    ' Create a list field - an array of the DDoS sample flows.
    Dim formattedDDoSSampleFlowsList As New List(Of DedicatedServerApi.Formatted_DDoS_SampleFlows)

        If ddosDetailsInfoResult.DDoS_Details.Formattted_DDoS_SampleFlows_List.Count > 0 Then
            ' Note: had to add .ToList() as it was giving a syntax error: cannot be converted to a 1-dimensional array.
            ' Does not make sense as the "Formattted_DDoS_SampleFlows_List" variable is defined exactly like the receiving field.
            formattedDDoSSampleFlowsList = ddosDetailsInfoResult.DDoS_Details.Formattted_DDoS_SampleFlows_List.ToList()

            For Each formattedDDoSSampleFlow In formattedDDoSSampleFlowsList

                ' Example of entry in the list:    [1/16/2015 10:30:14 PM] 241.167.2.72:5

                strSampleFlowLine = formattedDDoSSampleFlow.ToString() & vbCrLf & vbCrLf

                ' Build the sample flow list textbox.
                txtGDHDApiSampleFlowList.Text = txtGDHDApiSampleFlowList.Text & strSampleFlowLine
            Next
        Else
            'An empty list.
            txtGDHDApiSampleFlowList.Text = ""
        End If

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds formatted DDoS sample flows settings.
'   [1/16/2015 10:30:14 PM] 241.167.2.72:5
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class Formatted_DDoS_SampleFlows
    Private _open_bracket_delimeter As String

    Public Property Open_Bracket_Delimeter() As String
        Get
            Return _open_bracket_delimeter
        End Get

        Set(value As String)
            _open_bracket_delimeter = value
        End Set
    End Property

    Private _time_received As Date

    Public Property Time_Received() As Date
        Get
            Return _time_received
        End Get

        Set(value As Date)
            _time_received = value
        End Set
    End Property

    Private _close_backet_and_space_delimeter As String

    Public Property Close_Bracket_And_Space_Delimeter() As String
        Get
            Return _close_backet_and_space_delimeter
        End Get

        Set(value As String)
            _close_backet_and_space_delimeter = value
        End Set
    End Property

    Private _source_ip As String

    Public Property Source_IP() As String
        Get
            Return _source_ip
        End Get

        Set(value As String)
            _source_ip = value
        End Set
    End Property

    Private _colon1_delimeter As String

    Public Property Colon1_Delimeter() As String
        Get
            Return _colon1_delimeter
        End Get

        Set(value As String)
            _colon1_delimeter = value
        End Set
    End Property

    Private _source_port As String

    Public Property Source_Port() As String
        Get
            Return _source_port
        End Get

        Set(value As String)
            _source_port = value
        End Set
    End Property 
End Class

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds DDoSDetailsInfoResult.
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class DDoSDetailsInfoResult
    Private _message As String

    Public Property Message() As String
        Get
            Return _message
        End Get

        Set(value As String)
            _message = value
        End Set
    End Property

    Private _ddos_details As New DDoS_Details

    Public Property DDoS_Details() As DDoS_Details
        Get
            Return _ddos_details
        End Get

        Set(ByVal value As DDoS_Details)
            _ddos_details = value
        End Set
    End Property
End Class    

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds DDoS details.
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class DDoS_Details
    Private _formatted_ddos_sampleflows_list As New List(Of Formatted_DDoS_SampleFlows)

    Public Property Formattted_DDoS_SampleFlows_List() As List(Of Formatted_DDoS_SampleFlows)
        Get
            Return _formatted_ddos_sampleflows_list
        End Get

        Set(ByVal value As List(Of Formatted_DDoS_SampleFlows))
            _formatted_ddos_sampleflows_list = value
        End Set
    End Property
End Class
1
  • Any Ideas? - override ToString() in ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows? Commented Jun 17, 2015 at 19:04

2 Answers 2

2

Your Formatted_DDoS_SampleFlows class need to define what ToString does.

Something like:

Class Formatted_DDoS_SampleFlows

    Public Overrides ToString() As String

        Return _open_bracket_delimeter & _time_received.ToString() & _close_backet_and_space_delimeter & _source_ip
    End Sub

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

3 Comments

Thanks...it works. Been fighting with this all morning. I coded it as: Overrides Function ToString() As String Return _open_bracket_delimeter & _time_received.ToString() & _close_backet_and_space_delimeter & _source_ip & _colon1_delimeter & _source_port End Function
I have to qualify that now. It works in the local console app i created to mimic the web client calling the WCF service. However when I add the ToString() override to the WCF services data class and then reference that dataclass class from the client, I get the same error. If I hover over the ToString() it does not recognize the override function. It does recognize in the console app.
@user3020047 It's hard to figure out without seeing the code. If you create a function called GetInfoAsString() and call this function instead of the ToString() does it work?
0

use CDate to convert the original value into a Date. The ToString is being operated on the entire class. Then use String.Format to output the date into the correct format you want. Should look something closer to this:

strSampleFlowLine = String.Format("MM/dd/yyyy", CDate(formattedDDoSSampleFlow.something)) & vbCrLf & vbCrLf

Comments

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.