Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. public class Tools
  2.     {
  3.         /// <summary>
  4.         /// Lock this object to mark part of code for single thread execution
  5.         /// </summary>
  6.         public static object SyncObject = new object();
  7.  
  8.         public string TruncateLongString(string inputString, int maxChars, string postfix = ".")
  9.         {
  10.             if (maxChars <= 0)
  11.                 throw new ArgumentOutOfRangeException("maxChars");            
  12.             if (inputString == null || inputString.Length < maxChars)
  13.                 return inputString;
  14.  
  15.             var truncatedString = inputString.Substring(0, maxChars) + postfix;
  16.  
  17.             return truncatedString;
  18.  
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement