C# – How to generate random password

This article delivers proposal of algorithm to generate random passwords or actually random strings which are generated in safe manner and can be used as passwords, discount codes etc. Also, it is configurable, so that you can easily define expected length of string, pool of available characters or minimal number of occurrences of particular elements. All is encapsulated within a class, ready to reuse in your project. In this articles we’ll go through small code snippets and describe them in details, but full class can be also found at the end.

Continue reading C# – How to generate random password

C# – How to split a string

String can be split into collection of substrings based on a defined character (separator) using Split() function. Split is part of String class which exists in the System namespace.

Split function is overloaded and has various forms which allow to:

  • pass separator as a single character, array of characters, single string or array of strings;
  • define maximum number of substrings in output array;
  • define split options like removing empty elements from returned collection.
Continue reading C# – How to split a string