RemoveAt() public méthode

Removes the character from the formatted string at the specified position and shifts characters left. True if character shifting is successful.
public RemoveAt ( int position ) : bool
position int
Résultat bool
        private bool CanDelete( int startPosition, int selectionLength, bool deleteForward, MaskedTextProvider provider )
        {
            if( this.IsReadOnly )
            return false;

              if( selectionLength == 0 )
              {
            if( !deleteForward )
            {
              if( startPosition == 0 )
            return false;

              startPosition--;
            }
            else if( ( startPosition + selectionLength ) == provider.Length )
            {
              return false;
            }
              }

              MaskedTextResultHint notUsed;
              int tentativeCaretPosition = startPosition;

              int endPosition = ( selectionLength > 0 ) ? ( ( startPosition + selectionLength ) - 1 ) : startPosition;

              bool success = provider.RemoveAt( startPosition, endPosition, out tentativeCaretPosition, out notUsed );

              return success;
        }
        internal virtual bool CanReplace( MaskedTextProvider provider, string text, int startPosition, int selectionLength, bool rejectInputOnFirstFailure, out int tentativeCaretIndex )
        {
            int endPosition = ( startPosition + selectionLength ) - 1;
              tentativeCaretIndex = -1;

              bool success = false;

              foreach( char ch in text )
              {
            if( !m_maskedTextProvider.VerifyEscapeChar( ch, startPosition ) )
            {
              int editPositionFrom = provider.FindEditPositionFrom( startPosition, true );

              if( editPositionFrom == MaskedTextProvider.InvalidIndex )
            break;

              startPosition = editPositionFrom;
            }

            int length = ( endPosition >= startPosition ) ? 1 : 0;
            bool overwrite = length > 0;

            if( this.PlaceChar( provider, ch, startPosition, length, overwrite, out tentativeCaretIndex ) )
            {
              // Only one successfully inserted character is enough to declare the replace operation successful.
              success = true;

              startPosition = tentativeCaretIndex + 1;
            }
            else if( rejectInputOnFirstFailure )
            {
              return false;
            }
              }

              if( ( selectionLength > 0 ) && ( startPosition <= endPosition ) )
              {

            // Erase the remaining of the assigned edit character.
            int notUsed;
            MaskedTextResultHint notUsedHint;
            if( !provider.RemoveAt( startPosition, endPosition, out notUsed, out notUsedHint ) )
              success = false;
              }

              return success;
        }
		public void RemoveAtTest ()
		{
			MaskedTextProvider mtp;
			int Int32_out = 0;
			MaskedTextResultHint MaskedTextResultHint_out = MaskedTextResultHint.Unknown;
			mtp = new MaskedTextProvider (@"aaaaaaaaaaaa");
			mtp.Add ("123456789");
			mtp.RemoveAt (3, 6, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (3, Int32_out, "#A1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#A2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_A", 1, true, false, 5, 7, CultureInfo.GetCultureInfo ("es-ES"), 12, true, false, false, 4, 12, @"aaaaaaaaaaaa", true, false, '\x0', '\x5F', true, true, true, @"12389", @"12389", @"12389", @"12389_______", @"12389_______", @"12389", @"12389");

			mtp = new MaskedTextProvider (@"La");
			mtp.Add ("z1");
			mtp.RemoveAt (0, 1, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, Int32_out, "#B1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#B2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_B", 1, true, false, 0, 2, CultureInfo.GetCultureInfo ("es-ES"), 2, true, false, false, -1, 2, @"La", false, false, '\x0', '\x5F', true, true, true, @"", @"", @"", @"__", @"__", @"", @"");

			mtp = new MaskedTextProvider (@"La");
			mtp.Add ("z1");
			mtp.RemoveAt (0, 1, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, Int32_out, "#B1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#B2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_B", 1, true, false, 0, 2, CultureInfo.GetCultureInfo ("es-ES"), 2, true, false, false, -1, 2, @"La", false, false, '\x0', '\x5F', true, true, true, @"", @"", @"", @"__", @"__", @"", @"");

			// Remove non-assigned character with assigned characters later on.
			mtp = new MaskedTextProvider (@"aaaaaaaaaaaa");
			mtp.InsertAt ("1", 1);
			mtp.RemoveAt (0, 0, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, Int32_out, "#C1");
			Assert.AreEqual (MaskedTextResultHint.SideEffect, MaskedTextResultHint_out, "#C2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_C", 1, true, false, 1, 11, CultureInfo.GetCultureInfo ("es-ES"), 12, true, false, false, 0, 12, @"aaaaaaaaaaaa", true, false, '\x0', '\x5F', true, true, true, @"1", @"1", @"1", @"1___________", @"1___________", @"1", @"1");

			// Remove assigned+non-assigned character with assigned characters later on.
			mtp = new MaskedTextProvider (@"aaaaaaaaaaaa");
			mtp.InsertAt ("1", 1);
			mtp.InsertAt ("4", 4);
			mtp.RemoveAt (1, 2, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (1, Int32_out, "#D1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#D2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_D", 1, true, false, 1, 11, CultureInfo.GetCultureInfo ("es-ES"), 12, true, false, false, 2, 12, @"aaaaaaaaaaaa", true, false, '\x0', '\x5F', true, true, true, @"  4", @"  4", @"  4", @"__4_________", @"__4_________", @"  4", @"  4");

			// Remove non-assigned+assigned character with assigned characters later on.
			mtp = new MaskedTextProvider (@"aaaaaaaaaaaa");
			mtp.InsertAt ("1", 1);
			mtp.InsertAt ("4", 4);
			mtp.RemoveAt (0, 1, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, Int32_out, "#E1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#E2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_E", 1, true, false, 1, 11, CultureInfo.GetCultureInfo ("es-ES"), 12, true, false, false, 2, 12, @"aaaaaaaaaaaa", true, false, '\x0', '\x5F', true, true, true, @"  4", @"  4", @"  4", @"__4_________", @"__4_________", @"  4", @"  4");

			// Remove 2 characters with a assigned character just after that cannot be removed 1 character.
			mtp = new MaskedTextProvider (@"aaaLaaaaaaaa");
			mtp.Add ("012Z4");
			mtp.RemoveAt (0, 1, out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, Int32_out, "#F1");
			Assert.AreEqual (MaskedTextResultHint.Success, MaskedTextResultHint_out, "#F2");
			MaskedTextProviderTest.AssertProperties (mtp, "RemoveAtTest_F", 1, true, false, 3, 9, CultureInfo.GetCultureInfo ("es-ES"), 12, true, false, false, 2, 12, @"aaaLaaaaaaaa", false, false, '\x0', '\x5F', true, true, true, @"2Z4", @"2Z4", @"2Z4", @"2Z4_________", @"2Z4_________", @"2Z4", @"2Z4");

		}