aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
blob: 049c9c4afc02ef7e8574f45b13ada6e5db882b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public static class StringExtensions
{
    /// <summary>
    /// Normal ToString conversion with null checking.
    /// </summary>
    /// <param name="obj">The object.</param>
    /// <returns></returns>
    public static String ToStringSafe(this object obj)
    {
        return obj != null ? obj.ToString() : String.Empty;
    }

    /// <summary>
    /// Splits the string to lines.
    /// </summary>
    /// <param name="str">The string.</param>
    /// <returns></returns>
    public static List<String> ToLines(this String str)
    {
        return str.Split(new[] { '\r', '\n' }).ToList();
    }
}