mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Fixing null ref in array formatting
This commit is contained in:
@@ -115,6 +115,16 @@ namespace ICD.Common.Utils
|
|||||||
return string.Join("", strings);
|
return string.Join("", strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses String.Format to properly handle null values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToString(object value)
|
||||||
|
{
|
||||||
|
return string.Format("{0}", value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts bytes to an ascii string.
|
/// Converts bytes to an ascii string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -360,7 +370,7 @@ namespace ICD.Common.Utils
|
|||||||
if (items == null)
|
if (items == null)
|
||||||
throw new ArgumentNullException("items");
|
throw new ArgumentNullException("items");
|
||||||
|
|
||||||
return string.Format("[{0}]", string.Join(", ", items.Select(i => i.ToString()).ToArray()));
|
return string.Format("[{0}]", string.Join(", ", items.Select(i => ToString(i)).ToArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -377,7 +387,7 @@ namespace ICD.Common.Utils
|
|||||||
|
|
||||||
string[] ranges = MathUtils.GetRanges(items)
|
string[] ranges = MathUtils.GetRanges(items)
|
||||||
.Select(r => r[0] == r[1]
|
.Select(r => r[0] == r[1]
|
||||||
? r[0].ToString()
|
? ToString(r[0])
|
||||||
: string.Format("{0}-{1}", r[0], r[1]))
|
: string.Format("{0}-{1}", r[0], r[1]))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user