Code Snippet – C#: Prüfen ob ein String eine gültige Zahl ist / ein gültiger Alpha-numerischer String

public bool IsAlphaNumericString(string strAlphanum) {     System.Text.RegularExpressions.Regex pattern = new System.Text.RegularExpressions.Regex(@"^[A-Za-z0-9]+$");     return pattern.IsMatch(strAlphanum.Trim()); } public bool IsNumeric(string strAlphanum) {     System.Text.RegularExpressions.Regex pattern = new System.Text.RegularExpressions.Regex(@"^[0-9]+$");     return pattern.IsMatch(strAlphanum.Trim()); }

Code Snippet – C#: Generate square thumbnails

To generate a square thumbnail in c#, use this code: public Bitmap Generate75x75Pixel(Bitmap image) {     if(image == null)     throw new ArgumentNullException(„image“);     Bitmap bmp = null;     Bitmap crapped = null;     int x = 0, y = 0;     double prop = 0;     if(image.Width > 75) {         // compute proportation         prop = (double)image.Width / (double)image.Height;         if(image.Width > image.Height)… Code Snippet – C#: Generate square thumbnails weiterlesen