コード例 #1
0
    public void TestJoin()
    {
        System.Collections.Generic.List <int> intList = new System.Collections.Generic.List <int>()
        {
            1, 2, 3, 4, 5, 6, 7, 8, 9
        };
        Assert.AreEqual("1,2,3,4,5,6,7,8,9", intList.Join());
        Assert.AreEqual("123456789", intList.Join(""));
        Assert.AreEqual("1__2__3__4__5__6__7__8__9", intList.Join("__"));

        string[] strArray = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
        Assert.AreEqual("1,2,3,4,5,6,7,8,9", strArray.Join());
        Assert.AreEqual("123456789", strArray.Join(""));
        Assert.AreEqual("1__2__3__4__5__6__7__8__9", strArray.Join("__"));

        bool[] nullArray = null;
        Assert.Throws(typeof(System.ArgumentException), () => strArray.Join(null));
        Assert.Throws(typeof(System.ArgumentException), () => nullArray.Join());
    }