-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFirst.cs
More file actions
25 lines (22 loc) · 970 Bytes
/
First.cs
File metadata and controls
25 lines (22 loc) · 970 Bytes
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
using System.Linq;
namespace ToSic.Razor.Blade
{
public static partial class Text
{
/// <summary>
/// Try to return the first possible value, but if it's empty, return null
/// </summary>
/// <param name="values">array of values to check consecutively</param>
/// <returns></returns>
public static string First(params string[] values)
=> First(true, values);
/// <summary>
/// Try to return the first possible value, but if it's empty, return null
/// </summary>
/// <param name="values">array of values to check consecutively</param>
/// <param name="handleHtmlWhitespaces">if true (default) will treat html-whitespace as a space</param>
/// <returns></returns>
public static string First(bool handleHtmlWhitespaces = true, params string[] values)
=> values.FirstOrDefault(value => Has(value, handleHtmlWhitespaces));
}
}