Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7553457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:03:41+00:00 2026-05-30T11:03:41+00:00

I am having trouble understanding the difference between these two commands that in my

  • 0

I am having trouble understanding the difference between these two commands that in my mind should do the same thing. I have posted the entire code below in case anything is unclear.

I have created two functions in class Person, one that returns a list containing first,middle and last names and one that returns a concatenated string of the name. I reference the function that returns the list to concatenate the string with the line below:

FullName = String.Join(" ", Me.Get_NameList())

However, when I call:

Console.WriteLine(Person1.Print_Name())

I get what looks like the list object instead of the string:

System.Collections.Generic.List`1[System.String]

If I change the code to look like this:

    Public Function Print_Name()
        Dim FullNameList As List(Of String) = Me.Get_NameList()
        Dim FullName As String
        FullName = String.Join(" ", FullNameList)
        Return FullName
    End Function

The console prints:

John Q Doe

Why am I getting a different answer by first assigning the list to a variable and then joining it? Does this have something to do with how the list is stored in memory?

Thanks in advance for the help.

Here is the full code:

Imports System
Module Module1
    Sub Main()
        Dim Person1 As New Person("John", "Q", "Doe")
        Console.WriteLine("Get_Name Values")
        Dim g1 As List(Of String) = Person1.Get_NameList()
        Console.WriteLine(String.Join(" ", g1))
        Console.WriteLine("Print_Name Values")
        Console.WriteLine(Person1.Print_Name())
    End Sub
End Module

Class Person
    Private FirstName As String
    Private MiddleName As String
    Private LastName As String
    Public Sub New(ByVal Fn As String, ByVal Mn As String, ByVal Ln As String)
        FirstName = Fn
        MiddleName = Mn
        LastName = Ln
    End Sub
    Public Function Get_NameList()
        Dim NameList As New List(Of String)
        NameList.Add(FirstName)
        NameList.Add(MiddleName)
        NameList.Add(LastName)
        Return NameList
    End Function
    Public Function Print_Name()
        'Dim FullNameList As List(Of String) = Me.Get_NameList()
        Dim FullName As String
        FullName = String.Join(" ", Me.Get_NameList())
        Return FullName
    End Function
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:03:43+00:00Added an answer on May 30, 2026 at 11:03 am

    GetNameList returns an Object (because you don’t specify the return type).

    So the Join method is getting an object. So the VB.Net is turning the Object into a String() with one element that is Object.ToString(). Sometimes the method, especially if it is an old school VB holdover, would check to see if the object passed was an IEnumerable and just iterate over the Objects in the passed object. But not always. So having Strict and Explicit OFF can lead to very strange and hard to find bugs. Those two things should only be OFF in very specific cases where you want all the flexibility turning them off gives you AND you are ready to deal with the oddities that result.

    Change the return type of Get_NameList to List(Of String)

    And turn on option Strict ON and Option Explicit On to see your other problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble understanding the difference between these two code segments: I allocate
I am having trouble understanding the difference between a 32 bit processor and 64
I am having trouble with understanding the difference between ADDNES and ADDSNE in ARM
I am having trouble understanding the concept between two things being equal and two
I am learning algorithm analysis. I am having trouble understanding the difference between O,
I am having some trouble understanding the difference between @OneToMany and @ManyToMany . When
I'm having trouble understanding the difference between private and protected members in a C++
I'm having trouble understanding the difference between the jquery-rails ruby gem & jRails .
I'm having some trouble understanding the difference between asynchronous and synchronous Javascript, and was
I am having trouble in understanding what is the difference between the service context

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.