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 7780085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:48:31+00:00 2026-06-01T18:48:31+00:00

Using string.Join(,, test); works but for some reason I get an output of: Ilistprac.Location,

  • 0

Using “string.Join(“,”, test);” works but for some reason I get an output of:

“Ilistprac.Location, Ilistprac.Location, Ilistprac.Location”

I tried ToString, Convert.ToString, etc and I still get that output.

All the IList interfaces are implemented with the IEnurmerable too (just not listed here unless someone wants me to).

class IList2
{
    static void Main(string[] args)
    {

     string sSite = "test";

 string sBldg = "test32";
     string sSite1 = "test";
     string sSite2 = "test";

     Locations test = new Locations();
     Location loc = new Location();
     test.Add(sSite, sBldg)
     test.Add(sSite1)
     test.Add(sSite2)
     string printitout = string.Join(",", test); //having issues outputting whats on the list

     }
 }
string printitout = string.Join(",", test.ToArray<Location>);


public class Location
{
    public Location()
    {

    }
    private string _site = string.Empty;
    public string Site
    {
        get { return _site; }
        set { _site = value; }
    }
}

public class Locations : IList<Location>
{
    List<Location> _locs = new List<Location>();

    public Locations() { }

    public void Add(string sSite)
    {
        Location loc = new Location();
        loc.Site = sSite;

        loc.Bldg = sBldg;
        _locs.Add(loc);
    }

    private string _bldg = string.Empty;

    public string Bldg

    {

        get { return _bldg; }

        set { _bldg = value; }

    }


 }
  • 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-06-01T18:48:32+00:00Added an answer on June 1, 2026 at 6:48 pm

    You need to supply a useful ToString implementation for Location as Join is calling that for each element. The default implementation will just return the name of the type. See documentation.

    So if you have a type like

    class SomeType
    {
        public string FirstName { get; private set;  }
        public string LastName { get; private set; }
    
        public SomeType(string first, string last)
        {
            FirstName = first;
            LastName = last;
        }
    
        public override string ToString()
        {
            return string.Format("{0}, {1}", LastName, FirstName);
        }
    }
    

    You need to specify how that should be represented as a string. If you do that, you can use string.Join like this to produce the output below.

    var names = new List<SomeType> { 
        new SomeType("Homer", "Simpson"), 
        new SomeType("Marge", "Simpson") 
    };
    
    Console.WriteLine(string.Join("\n", names));
    

    Output:

    Simpson, Homer
    Simpson, Marge
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does string.join resolve? I tried using it as below: import string list_of_str =
I am using string template to render some content, but the content may be
I'm converting an array into a string using String.Join . A small issue I
I'm trying to implement the first example http://www.dotnetperls.com/convert-list-string into my method but I'm having
I'm using Doctrine2+CodeIgniter2, and am attempting to create a simple test of a join
Using String.Format how can i ensure all numbers have commas after every 3 digits
Friends i'm using string builder for generating Passenger List in which i have used
I have made a String[] array by using String.split(.) . I am now trying
I add GroupBoxes to an ItemsControl dynamically using: string name_ = TestName, header_ =
I am using JDK 7 and Netbeans IDE 7.1.2. Going through Using string in

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.