Recent Changes - Search:

Oktatás

* Programozás 2
  + feladatsor
  + C feladatsor
  + Python feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

* levelezősök
  + Adator. prog.
  + feladatsor
  + quick link

teaching assets


Félévek

* 2024/25/1
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

20180403d

string.Join

csharp> var li = new List<string> {"aa", "bb", "cc", "dd"}

csharp> string.Join("", li)
"aabbccdd"                                                                                                                                                                

csharp> string.Join(",", li)
"aa,bb,cc,dd"                                                                                                                                                            

csharp> string.Join("--", li)
"aa--bb--cc--dd"

csharp> var li = new List<int> {1, 2, 3, 4}
csharp> string.Join("", li)                    // works with numbers too
"1234"

It also works with numbers, for instance. No need to convert the numbers to strings first.


string.Concat

If you simply want to concatenate the elements, then you can also use string.Concat(), which is equivalent to joining where the delimiter is the empty string.

csharp> var li = new List<string> {"aa", "bb", "cc", "dd"}

csharp> string.Concat(li)
"aabbccdd"                                                                                                                                                                

csharp> var li = new List<int> {1, 2, 3, 4}
csharp> string.Concat(li)                      // works with numbers too
"1234"

It also works with numbers.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2018 April 07, 11:48