本文整理汇总了C#中Array类的典型用法代码示例。如果您正苦于以下问题:C# Array类的具体用法?C# Array怎么用?C# Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Array类属于命名空间,在下文中一共展示了Array类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetByte
public static byte GetByte (Array array, int index)
{
if (index < 0 || index >= ByteLength (array))
throw new ArgumentOutOfRangeException ("index");
return _GetByte (array, index);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:Buffer.cs
示例2: SimpleSort
/// <summary>
/// A simple bubble sort for two arrays, limited to some region of the arrays.
/// This is a regular bubble sort, nothing fancy.
/// </summary>
public static void SimpleSort(Array array, Array items, int startingIndex, int length, IComparer comparer)
{
bool finished = false;
while (!finished)
{
bool swapped = false;
for (int g = startingIndex; g < startingIndex + length - 1; g++)
{
Object first = array.GetValue(g);
Object second = array.GetValue(g + 1);
int comparison = comparer.Compare(first, second);
if (comparison == 1)
{
Swap(g, g + 1, array, items);
swapped = true;
first = array.GetValue(g);
second = array.GetValue(g + 1);
}
}
if (!swapped)
{
finished = true;
}
}
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:30,代码来源:Array.Util.cs
示例3: SetByte
public static void SetByte (Array array, int index, byte value)
{
if (index < 0 || index >= ByteLength (array))
throw new ArgumentOutOfRangeException ("index");
_SetByte (array, index, value);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:Buffer.cs
示例4: concat
public static Array concat( Array lhs,Array rhs )
{
Array res=Array.CreateInstance( lhs.GetType().GetElementType(),lhs.Length+rhs.Length );
Array.Copy( lhs,0,res,0,lhs.Length );
Array.Copy( rhs,0,res,lhs.Length,rhs.Length );
return res;
}
开发者ID:JochenHeizmann,项目名称:monkey,代码行数:7,代码来源:lang.cs
示例5: BlockCopy
public static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
{
for (var i = 0; i < count; i++)
{
dst[i + dstOffset] = src[i + srcOffset];
}
}
开发者ID:sbrown345,项目名称:quakejs,代码行数:7,代码来源:Buffer.cs
示例6: decryptWithForce
//Decrypt specified cypher with force
public string decryptWithForce(string encryptedMessage)
{
byte[] originalMessageInAscii = Encoding.ASCII.GetBytes(encryptedMessage);
byte[] changedMessage = new Array(originalMessageInAscii.GetLength());
int length = originalMessageInAscii.GetLength();
//Checks each letter of the alphabet (lower case only)
for(int i = 0; i < 26; i++)
{
//Shifts ascii value in originalMessage by i to check
for (int j = 0; j < length; j++)
{
changedMessage[j] = originalMessageInAscii[j] + i;
if
Console.WriteLine(Encoding.ASCII.GetString(changedMessage, 0, length));
}
}
/*
foreach (byte b in messageInAscii)
{
Console.WriteLine(b);
}*/
}
开发者ID:bergbla16,项目名称:EncryptionProject,代码行数:29,代码来源:TextDecryption.cs
示例7: InitializeArray
public static void InitializeArray (Array array, RuntimeFieldHandle fldHandle)
{
if ((array == null) || (fldHandle.Value == IntPtr.Zero))
throw new ArgumentNullException ();
InitializeArray (array, fldHandle.Value);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:RuntimeHelpers.Original.cs
示例8: BlockCopy
public static void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count)
{
if (src == null)
throw new ArgumentNullException ("src");
if (dst == null)
throw new ArgumentNullException ("dst");
if (srcOffset < 0)
throw new ArgumentOutOfRangeException ("srcOffset", Locale.GetText(
"Non-negative number required."));
if (dstOffset < 0)
throw new ArgumentOutOfRangeException ("dstOffset", Locale.GetText (
"Non-negative number required."));
if (count < 0)
throw new ArgumentOutOfRangeException ("count", Locale.GetText (
"Non-negative number required."));
// We do the checks in unmanaged code for performance reasons
bool res = InternalBlockCopy (src, srcOffset, dst, dstOffset, count);
if (!res) {
// watch for integer overflow
if ((srcOffset > ByteLength (src) - count) || (dstOffset > ByteLength (dst) - count))
throw new ArgumentException (Locale.GetText (
"Offset and length were out of bounds for the array or count is greater than " +
"the number of elements from index to the end of the source collection."));
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:30,代码来源:Buffer.cs
示例9: Copy
/// <summary>
///
/// </summary>
public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
for (int s = 0, d = destinationIndex; s < length; s++, d++)
{
sourceArray.SetValue(destinationArray.GetValue(d), s + sourceIndex);
}
}
开发者ID:ExpressOS,项目名称:third_party-korlib,代码行数:10,代码来源:Array.cs
示例10: read_config
public static string read_config(Array path, string default_val)
{
Hashtable current_crumb = mvid_config;
foreach (string v in path)
{
if (current_crumb[v] != null)
{
if (current_crumb[v].GetType() == typeof(Hashtable))
{
current_crumb = (Hashtable)current_crumb[v];
}
else
{
return current_crumb[v].ToString();
}
}
else
{
if (default_val != null)
{
return default_val;
}
return null;
}
}
return current_crumb.Values.ToString();
}
开发者ID:mikrov,项目名称:mvid-cs,代码行数:27,代码来源:mvid-config.cs
示例11: ArrayInfo
static void ArrayInfo(String name, Array a)
{
Console.Write("{0} has length={1} rank={2} [", name, a.Length, a.Rank);
for (int i = 0, stop=a.Rank; i<stop; i++)
Console.Write(" {0}", a.GetLength(i));
Console.WriteLine(" ]");
}
开发者ID:walrus7521,项目名称:code,代码行数:7,代码来源:Arrays.cs
示例12: ArrayLength
static long ArrayLength(Array array, int i)
{
long n = 1;
for ( ; i < array.Rank; i++ )
n *= array.GetLength(i);
return n;
}
开发者ID:jbruening,项目名称:YamlSerializer-Fork,代码行数:7,代码来源:YamlRepresenter.cs
示例13: CopyTo
public virtual void CopyTo(Array array, int index)
{
if (array == null)
{
throw new ArgumentNullException("array");
}
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
if ((array.Length - index) < this._size)
{
throw new ArgumentException();
}
int num = 0;
if (array is object[])
{
object[] objArray = (object[])array;
while (num < this._size)
{
objArray[num + index] = this._array[(this._size - num) - 1];
num++;
}
}
else
{
while (num < this._size)
{
array.SetValue(this._array[(this._size - num) - 1], (int)(num + index));
num++;
}
}
}
开发者ID:modulexcite,项目名称:IL2JS,代码行数:33,代码来源:Stack.cs
示例14:
// Implement the ICollection interface.
void ICollection.CopyTo(Array array, int index)
{
lock(this)
{
list.CopyTo(array, index);
}
}
开发者ID:moljac,项目名称:System.Diagnostics,代码行数:8,代码来源:TraceListenerCollection.cs
示例15: CopyTo
public void CopyTo (Array dest, int index)
{
/* XXX this is kind of gross and inefficient
* since it makes a copy of the superclass's
* list */
object[] values = BaseGetAllValues();
values.CopyTo (dest, index);
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:HttpModuleCollection.cs
示例16: resizeArray
public static Array resizeArray( Array arr,int len )
{
Type ty=arr.GetType().GetElementType();
Array res=Array.CreateInstance( ty,len );
int n=Math.Min( arr.Length,len );
if( n>0 ) Array.Copy( arr,res,n );
return res;
}
开发者ID:JochenHeizmann,项目名称:monkey,代码行数:8,代码来源:lang.cs
示例17: PrintValues
//a helper function for displaying the values of an Array
public static void PrintValues(Array myArr)
{
foreach (int i in myArr)
{
Console.Write(i);
}
Console.WriteLine();
}
开发者ID:KostaDinkov,项目名称:TelerikAcademy,代码行数:9,代码来源:BitExchange.cs
示例18: AssertAllArrayElementsAreEqual
/// <summary>
/// Asserts that each element in the first array is equal to its corresponding element in the second array.
/// </summary>
public static void AssertAllArrayElementsAreEqual(Array first, Array second, IComparer comparer = null)
{
Assert.True(first.Length == second.Length, "The two arrays are not even the same size.");
for (int g = first.GetLowerBound(0); g < first.GetUpperBound(0); g++)
{
AssertArrayElementsAreEqual(first, second, g, comparer);
}
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:11,代码来源:Array.Util.cs
示例19: catString
private string catString(Array cat)
{
string str = "--";
for(int i=0; i < cat.Length; i++)
{
str += cat.GetValue(i) + " |";
}
return str+"|\n";
}
开发者ID:snotwadd20,项目名称:UnityLevelGen,代码行数:9,代码来源:Journey.cs
示例20: printArr
void printArr(Array ar)
{
string temp = "";
for (int i = 0; i < ar.Length; i++)
{
temp += System.Environment.NewLine + ar.GetValue(i).ToString();
}
Console.WriteLine(temp);
}
开发者ID:ArildF,项目名称:masters,代码行数:9,代码来源:co8773performance.cs
注:本文中的Array类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论