CSharp examples for System.IO:File Size
Crops the string if the given size is smaller than the string length
using System.Linq; using System.Collections.Generic; public class Main{ /// <summary> /// Crops the string if the given size is smaller than the string length /// </summary> /// <param name="aString">the given string to be cropped</param> /// <param name="size">the maximum size of the string</param> /// <returns>the cropped string</returns> public static string Crop(this string aString, int size) {/*from w w w . j a va2 s . c o m*/ return aString.Length > size ? aString.Remove(size) : aString; } }