bovender framework
C# framework that implements MVVM and more
StringExtensions.cs
1
/* StringExtensions.cs
2
* part of Bovender framework
3
*
4
* Copyright 2014-2018 Daniel Kraus
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
using
System
;
19
using
System
.Collections.Generic;
20
using
System
.Linq;
21
using
System
.Text;
22
23
namespace
Bovender
.Extensions
24
{
25
public
static
class
StringExtensions
26
{
35
public
static
string
TruncateWithEllipsis
(
this
string
s,
int
length)
36
{
37
if
(length <= 5)
38
{
39
throw
new
ArgumentException(
"Cannot truncate string with ellipsis to 5 or less characters."
);
40
}
41
return
s.Length <= length ? s : s.Substring(0, length - 3) +
"..."
;
42
}
43
}
44
}
Bovender.Extensions.StringExtensions.TruncateWithEllipsis
static string TruncateWithEllipsis(this string s, int length)
Truncates a string and adds three dots (ellipsis) so that the resulting string is at most "<paramref ...
Definition:
StringExtensions.cs:35
Bovender.Extensions.StringExtensions
Definition:
StringExtensions.cs:25
Bovender
Definition:
ComHelpers.cs:24
System
Bovender
Extensions
StringExtensions.cs
Generated on Tue Aug 14 2018 13:04:33 for bovender framework by
1.8.11