本文整理汇总了C#中System.Security.SecureString.SetAt方法的典型用法代码示例。如果您正苦于以下问题:C# SecureString.SetAt方法的具体用法?C# SecureString.SetAt怎么用?C# SecureString.SetAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.SecureString
的用法示例。
在下文中一共展示了SecureString.SetAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnsafeConstructor
public unsafe void UnsafeConstructor ()
{
try {
SecureString ss = null;
char[] data = new char[] { 'a', 'b', 'c' };
fixed (char* p = &data[0]) {
ss = new SecureString (p, data.Length);
}
Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
Assert.AreEqual (3, ss.Length, "3");
ss.AppendChar ('a');
Assert.AreEqual (4, ss.Length, "4");
ss.Clear ();
Assert.AreEqual (0, ss.Length, "0b");
ss.InsertAt (0, 'b');
Assert.AreEqual (1, ss.Length, "1b");
ss.SetAt (0, 'c');
Assert.AreEqual (1, ss.Length, "1c");
ss.RemoveAt (0);
Assert.AreEqual (0, ss.Length, "0c");
ss.Dispose ();
}
catch (NotSupportedException) {
Assert.Ignore (NotSupported);
}
}
示例2: DefaultConstructor
public void DefaultConstructor ()
{
try {
SecureString ss = new SecureString ();
Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
Assert.AreEqual (0, ss.Length, "0");
ss.AppendChar ('a');
Assert.AreEqual (1, ss.Length, "1");
ss.Clear ();
Assert.AreEqual (0, ss.Length, "0b");
ss.InsertAt (0, 'b');
Assert.AreEqual (1, ss.Length, "1b");
ss.SetAt (0, 'c');
Assert.AreEqual (1, ss.Length, "1c");
Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString");
ss.RemoveAt (0);
Assert.AreEqual (0, ss.Length, "0c");
ss.Dispose ();
}
catch (NotSupportedException) {
Assert.Ignore (NotSupported);
}
}
示例3: SetAt_BiggerThanLength
public void SetAt_BiggerThanLength ()
{
SecureString ss = new SecureString ();
ss.SetAt (1, 'a');
}
示例4: SetAt_Negative
public void SetAt_Negative ()
{
SecureString ss = new SecureString ();
ss.SetAt (-1, 'a');
}