当前位置: 首页>>代码示例>>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;未经允许,请勿转载。