SetLength() public méthode

public SetLength ( long value ) : void
value long
Résultat void
Exemple #1
0
        public override void SetLength(long value)
        {
            CheckIfStreamClosed("SetLength");

            m_sb.SetLength(value);
            if (m_lPosition > value)
            {
                m_lPosition = value;
            }
        }
Exemple #2
0
        public override void SetLength(long value)
        {
            CheckIfStreamClosed();

            _sb.SetLength(value);
            if (_lPosition > value)
            {
                _lPosition = value;
            }
        }
		public void SqlBytesSetLength ()
		{
			byte [] b1 = new byte [10];
			SqlBytes bytes = new SqlBytes ();
			try {
				bytes.SetLength (20);
				Assert.Fail ("Should throw SqlTypeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (SqlTypeException), ex.GetType (), "Should throw SqlTypeException");
			}
			bytes = new SqlBytes (b1);
			Assert.AreEqual (bytes.Length, 10, "#1 Should be same");
			try {
				bytes.SetLength (-1);
				Assert.Fail ("Should throw ArgumentOutOfRangeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "Should throw ArgumentOutOfRangeException");
			}
			try {
				bytes.SetLength (11);
				Assert.Fail ("Should throw ArgumentOutOfRangeException");
			} catch (Exception ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "Should throw ArgumentOutOfRangeException");
			}
			bytes.SetLength (2);
			Assert.AreEqual (bytes.Length, 2, "#2 Should be same");
		}
Exemple #4
0
 public void SqlBytesSetLength()
 {
     byte[] b1 = new byte[10];
     SqlBytes bytes = new SqlBytes();
     try
     {
         bytes.SetLength(20);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(SqlTypeException), ex.GetType());
     }
     bytes = new SqlBytes(b1);
     Assert.Equal(bytes.Length, 10);
     try
     {
         bytes.SetLength(-1);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
     }
     try
     {
         bytes.SetLength(11);
         Assert.False(true);
     }
     catch (Exception ex)
     {
         Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
     }
     bytes.SetLength(2);
     Assert.Equal(bytes.Length, 2);
 }