Mega Code Archive

 
Categories / C# Tutorial / Security
 

Instantiates a new SecureString object by passing its constructor a pointer to a character array

using System; using System.Security; public class Example {    unsafe public static void Main()    {       SecureString testString;       char[] chars = { 't', 'e', 's', 't' };       fixed(char* pChars = chars)       {          testString = new SecureString(pChars, chars.Length);       }       Console.WriteLine(testString.Length);    } }