當前位置: 首頁>>代碼示例>>C#>>正文


C# Array.GetLongLength方法代碼示例

本文整理匯總了C#中System.Array.GetLongLength方法的典型用法代碼示例。如果您正苦於以下問題:C# Array.GetLongLength方法的具體用法?C# Array.GetLongLength怎麽用?C# Array.GetLongLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Array的用法示例。


在下文中一共展示了Array.GetLongLength方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FormatArrayTypeName

        private string FormatArrayTypeName(Type arrayType, Array arrayOpt, ObjectFormattingOptions options)
        {
            StringBuilder sb = new StringBuilder();

            // print the inner-most element type first:
            Type elementType = arrayType.GetElementType();
            while (elementType.IsArray)
            {
                elementType = elementType.GetElementType();
            }

            sb.Append(FormatTypeName(elementType, options));

            // print all components of a jagged array:
            Type type = arrayType;
            do
            {
                if (arrayOpt != null)
                {
                    sb.Append('[');

                    int rank = type.GetArrayRank();

                    bool anyNonzeroLowerBound = false;
                    for (int i = 0; i < rank; i++)
                    {
                        if (arrayOpt.GetLowerBound(i) > 0)
                        {
                            anyNonzeroLowerBound = true;
                            break;
                        }
                    }

                    for (int i = 0; i < rank; i++)
                    {
                        int lowerBound = arrayOpt.GetLowerBound(i);
                        long length = arrayOpt.GetLongLength(i);

                        if (i > 0)
                        {
                            sb.Append(", ");
                        }

                        if (anyNonzeroLowerBound)
                        {
                            AppendArrayBound(sb, lowerBound, options.UseHexadecimalNumbers);
                            sb.Append("..");
                            AppendArrayBound(sb, length + lowerBound, options.UseHexadecimalNumbers);
                        }
                        else
                        {
                            AppendArrayBound(sb, length, options.UseHexadecimalNumbers);
                        }
                    }

                    sb.Append(']');
                    arrayOpt = null;
                }
                else
                {
                    AppendArrayRank(sb, type);
                }

                type = type.GetElementType();
            }
            while (type.IsArray);

            return sb.ToString();
        }
開發者ID:Scalpel,項目名稱:roslyn,代碼行數:69,代碼來源:CSharpObjectFormatter.cs

示例2: CollectMultiArrayItems

            private void CollectMultiArrayItems(List<STypeInstanceProxy> items, Array array, int dimension, params long[] indices)
            {
                // visszaállítási adatok mentése
                long originalIndicesValueOnDimension = 0;
                if (dimension + 1 < array.GetType().GetArrayRank())
                {
                    originalIndicesValueOnDimension = indices[dimension + 1];
                }

                for (long i = 0; i < array.GetLongLength(dimension); i++)
                {
                    STypeInstanceProxy proxy = null;
                    indices[dimension] = i;

                    if (indices.Length - 1 == dimension)
                    {
                        object value = array.GetValue(indices);
                        if (value != null)
                        {
                            proxy = GetTypeInstanceProxy(value, value.GetType()); // array.GetType().GetElementType()
                        }
                    }
                    else
                    {
                        proxy = (STypeInstanceProxy)GetTypeInfo(array.GetType().GetElementType()).Clone();
                        bool firstTime = false;
                        proxy.InstanceId = mGenerator.GetId(proxy, out firstTime); //mProxyIdGenerator;
                        proxy.InstanceValue = dimension; // level of the array
                        proxy.IsArrayDimensionRepresentation = true;
                        mReferenceVsTypeInstances.Add(proxy.InstanceId, proxy);
                    }
                    items.Add(proxy);

                    if (dimension + 1 < array.GetType().GetArrayRank())
                    {
                        proxy.ArrayItems = new List<STypeInstanceProxy>();
                        CollectMultiArrayItems(proxy.ArrayItems, array, dimension + 1, indices);
                        indices[dimension + 1] = originalIndicesValueOnDimension;
                    }
                }
            }
開發者ID:JZO001,項目名稱:Forge,代碼行數:41,代碼來源:BinarySerializer.cs

示例3: DeclareArrayInitializer

        private void DeclareArrayInitializer(Array array, int dim, long[] indices, StringBuilder sb)
        {
            long length = array.GetLongLength(dim);
            sb.Append("(");
            if (length == 1)
            {
                sb.Append("0 => ");
            }
            int linelen = 0;
            for (long i = 0; i < length; i++)
            {
                if (i > 0)
                    sb.Append(",");
                ++linelen;
                if (linelen < 200)
                {
                    sb.Append(" ");
                }
                else
                {
                    sb.AppendLine();
                    linelen = 0;
                }

                indices[dim] = i;
                if (dim < array.Rank - 1)
                {
                    DeclareArrayInitializer(array, dim + 1, indices, sb);
                }
                else
                {
                    object element = array.GetValue(indices);
                    string value = GetValueID(element);
                    sb.Append(value);
                    linelen += value.Length;
                }
            }
            sb.Append(")");
        }
開發者ID:venusdharan,項目名稱:systemsharp,代碼行數:39,代碼來源:VHDLGen.cs

示例4: CollectArrayItems

 private void CollectArrayItems(List<STypeInstanceProxy> items, Array array, params long[] indices)
 {
     long length = array.GetLongLength(0);
     for (long i = 0; i < length; i++)
     {
         indices[0] = i;
         object arrayItem = array.GetValue(indices);
         if (arrayItem == null)
         {
             items.Add(null);
         }
         else if (arrayItem.GetType().IsGenericType && arrayItem.GetType().GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
         {
             items.Add(GetTypeInstanceProxy(arrayItem, arrayItem.GetType()));
         }
         else
         {
             items.Add(GetTypeInstanceProxy(arrayItem, null));
         }
     }
 }
開發者ID:JZO001,項目名稱:Forge,代碼行數:21,代碼來源:BinarySerializer.cs

示例5: DeclareArrayInitializer

        private void DeclareArrayInitializer(Array array, int dim, long[] indices, StringBuilder sb, string name)
        {
            long length = array.GetLongLength(dim);
            
            //sb.Append(" /*");
            //if (length == 1)
            //{
            //    sb.Append("0 => ");
            //}
            int linelen = 0;
            for (long i = 0; i < length; i++)
            {
                if (i > 0)
                    sb.Append(";");
                ++linelen;
                if (linelen < 200)
                {
                    sb.Append(" ");
                }
                else
                {
                    sb.AppendLine();
                    linelen = 0;
                }

                indices[dim] = i;
                if (dim < array.Rank - 1)
                {
                    DeclareArrayInitializer(array, dim + 1, indices, sb, name);
                }
                else
                {
                    object element = array.GetValue(indices);
                    string value = GetValueID(element);
                    if(dim == 0)
                        sb.Append(name + "[" + i + "] = " + value);
                    else
                        sb.Append(name + "[" + dim + "][" + i + "] = " + value);
                    linelen += value.Length;
                }
            }
            sb.Append(";");
            sb.AppendLine();
        }
開發者ID:venusdharan,項目名稱:systemsharp,代碼行數:44,代碼來源:SystemCGen.cs


注:本文中的System.Array.GetLongLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。