Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
// More projects: http://www.zzzprojects.com/
// Copyright ZZZ Projects Inc. 2014 - 2016. All rights reserved.
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
using System;

public static partial class Extensions
Expand Down Expand Up @@ -61,6 +61,10 @@ public static char ToCharOrDefault(this object @this, char defaultValue, bool us
{
return Convert.ToChar(@this);
}
catch (ArgumentNullException)
{
return default(char);
}
catch (Exception)
{
return defaultValue;
Expand Down Expand Up @@ -103,9 +107,13 @@ public static char ToCharOrDefault(this object @this, Func<char> defaultValueFac
{
return Convert.ToChar(@this);
}
catch (ArgumentNullException)
{
return default(char);
}
catch (Exception)
{
return defaultValueFactory();
}
}
}
}