Engines/FlatRedBallXNA/FlatRedBall/IO/Csv/CsvReader.cs
/// <summary>
/// Copy the value of the specified field to an array.
/// </summary>
/// <param name="field">The index of the field.</param>
/// <param name="fieldOffset">The offset in the field value.</param>
/// <param name="destinationArray">The destination array where the field value will be copied.</param>
/// <param name="destinationOffset">The destination array offset.</param>
/// <param name="length">The number of characters to copy from the field value.</param>
/// <returns></returns>
Copy the value of the specified field to an array.
Copy the value of the specified field to an array .
private long CopyFieldToArray(int field, long fieldOffset, Array destinationArray, int destinationOffset, int length)
		{
			EnsureInitialize();
			if (field < 0 || field >= _fieldCount)
				throw new ArgumentOutOfRangeException("field is bad: " + field);
			if (fieldOffset < 0 || fieldOffset >= int.MaxValue)
				throw new ArgumentOutOfRangeException("fieldOffset");
			if (length == 0)
				return 0;
			string value = this[field];
			if (value == null)
				value = string.Empty;
			Debug.Assert(fieldOffset < int.MaxValue);
			Debug.Assert(destinationArray.GetType() == typeof(char[]) || destinationArray.GetType() == typeof(byte[]));
            if (destinationArray.GetType() == typeof(char[]))
            {
                Array.Copy(value.Substring((int)fieldOffset, length).ToCharArray(), 0, destinationArray, destinationOffset, length);
            }
            else
            {
                char[] chars = value.Substring((int)fieldOffset, length).ToCharArray();
                byte[] source = new byte[chars.Length]; ;
                for (int i = 0; i < chars.Length; i++)
                    source[i] = Convert.ToByte(chars[i]);
                Array.Copy(source, 0, destinationArray, destinationOffset, length);
            }
			return length;
		}
private long CopyFieldToArray ( int field , long fieldOffset , Array destinationArray , int destinationOffset , int length ) { EnsureInitialize ( ) ; if ( field < 0 || field >= _fieldCount ) throw new ArgumentOutOfRangeException ( " " + field ) ; if ( fieldOffset < 0 || fieldOffset >= int . MaxValue ) throw new ArgumentOutOfRangeException ( " " ) ; if ( length == 0 ) return 0 ; string value = this [ field ] ; if ( value == null ) value = string . Empty ; Debug . Assert ( fieldOffset < int . MaxValue ) ; Debug . Assert ( destinationArray . GetType ( ) == typeof ( char [ ] ) || destinationArray . GetType ( ) == typeof ( byte [ ] ) ) ; if ( destinationArray . GetType ( ) == typeof ( char [ ] ) ) { Array . Copy ( value . Substring ( ( int ) fieldOffset , length ) . ToCharArray ( ) , 0 , destinationArray , destinationOffset , length ) ; } else { char [ ] chars = value . Substring ( ( int ) fieldOffset , length ) . ToCharArray ( ) ; byte [ ] source = new byte [ chars . Length ] ; ; for ( int i = 0 ; i < chars . Length ; i ++ ) source [ i ] = Convert . ToByte ( chars [ i ] ) ; Array . Copy ( source , 0 , destinationArray , destinationOffset , length ) ; } return length ; }
Copy the value of the specified field to an array.
Copy the value of the specified field to an array .
// Array.Copy(...) will do the remaining argument checks
None
field
int
The index of the field.
The index of the field .
fieldOffset
long
The offset in the field value.
The offset in the field value .
destinationArray
Array
The destination array where the field value will be copied.
The destination array where the field value will be copied .
destinationOffset
int
The destination array offset.
The destination array offset .
length
int
The number of characters to copy from the field value.
The number of characters to copy from the field value .