当前位置: 首页>>代码示例>>C#>>正文


C# Array.GetValue方法代码示例

本文整理汇总了C#中System.Array.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Array.GetValue方法的具体用法?C# Array.GetValue怎么用?C# Array.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Array的用法示例。


在下文中一共展示了Array.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CodeRepresentation

 public static string CodeRepresentation(Array a)
 {
     StringBuilder ret = new StringBuilder();
     ret.Append(a.GetType().FullName);
     ret.Append("(");
     switch (a.Rank) {
         case 1: {
                 for (int i = 0; i < a.Length; i++) {
                     if (i > 0) ret.Append(", ");
                     ret.Append(Ops.StringRepr(a.GetValue(i + a.GetLowerBound(0))));
                 }
             }
             break;
         case 2: {
                 int imax = a.GetLength(0);
                 int jmax = a.GetLength(1);
                 for (int i = 0; i < imax; i++) {
                     ret.Append("\n");
                     for (int j = 0; j < jmax; j++) {
                         if (j > 0) ret.Append(", ");
                         ret.Append(Ops.StringRepr(a.GetValue(i + a.GetLowerBound(0), j + a.GetLowerBound(1))));
                     }
                 }
             }
             break;
         default:
             ret.Append(" Multi-dimensional array ");
             break;
     }
     ret.Append(")");
     return ret.ToString();
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:32,代码来源:ArrayOps.cs

示例2: GetValue

 public static string GetValue(Array MyValues)
 {
     String ret = "";
        ret=MyValues.GetValue(1, RowIndex) == null?"":MyValues.GetValue(1, RowIndex).ToString();
        RowIndex++;
        return ret;
 }
开发者ID:techmio,项目名称:importer,代码行数:7,代码来源:ExcelTool.cs

示例3: Sort

 /// <summary>
 /// Sort elements in an Array object, using the Order
 /// delegate to determine how items should be sorted.
 /// </summary>
 /// <param name="table">Array to be sorted</param>
 /// <param name="sortHandler">Delegate to manage
 /// sort order.</param>
 public void Sort(Array table, Order sortHandler)
 {
     if(sortHandler == null)
         throw new ArgumentNullException();
     
     bool nothingSwapped = false;
     int pass = 1;
     while(nothingSwapped == false)
     {
         nothingSwapped = true;
         for(int index = 0; index < table.Length - pass; ++index)
         {
             // Use an Order delegate to determine the sort order.
             if(sortHandler(table.GetValue(index),
                 table.GetValue(index + 1)) == false)
             {
                 nothingSwapped = false;
                 object temp = table.GetValue(index);
                 table.SetValue(table.GetValue(index + 1), index);
                 table.SetValue(temp, index + 1);
             }
         }
         ++pass;
     }
 }
开发者ID:ppatoria,项目名称:SoftwareDevelopment,代码行数:32,代码来源:BUBBLESORT.CS

示例4: 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

示例5: SendEmail

        public bool SendEmail(string name, string email, Array arrayFrontEnd, Array arrayBackEnd, Array arrayMobile)
        {
            bool criterion = false;
            bool sucess = true;
            string subject = string.Empty;
            string content = string.Empty;
            IDictionary<int, string> dictionary = new Dictionary<int, string>();

            if (Convert.ToInt32(arrayFrontEnd.GetValue(0)) >= 7 || 10 <= Convert.ToInt32(arrayFrontEnd.GetValue(0)) &&
                Convert.ToInt32(arrayFrontEnd.GetValue(1)) >= 7 || 10 <= Convert.ToInt32(arrayFrontEnd.GetValue(1)) &&
                Convert.ToInt32(arrayFrontEnd.GetValue(2)) >= 7 || 10 <= Convert.ToInt32(arrayFrontEnd.GetValue(2)))
            {
                criterion = true;
                subject = string.Concat("Obrigado por se candidatar ", name);
                content = "Obrigado por se candidatar, assim que tivermos uma vaga disponível para programador Front-End entraremos em contato.";
                dictionary.Add(1, string.Concat(subject, "|", content));
            }

            if (Convert.ToInt32(arrayBackEnd.GetValue(0)) >= 7 || 10 <= Convert.ToInt32(arrayBackEnd.GetValue(0)) &&
                     Convert.ToInt32(arrayBackEnd.GetValue(1)) >= 7 || 10 <= Convert.ToInt32(arrayBackEnd.GetValue(1)))
            {
                criterion = true;
                subject = string.Concat("Obrigado por se candidatar ", name);
                content = "Obrigado por se candidatar, assim que tivermos uma vaga disponível para programador Back-End entraremos em contato.";
                dictionary.Add(2, string.Concat(subject, "|", content));
            }

            if (Convert.ToInt32(arrayMobile.GetValue(0)) >= 7 || 10 <= Convert.ToInt32(arrayMobile.GetValue(0)) &&
                     Convert.ToInt32(arrayMobile.GetValue(1)) >= 7 || 10 <= Convert.ToInt32(arrayMobile.GetValue(1)))
            {
                criterion = true;
                subject = string.Concat("Obrigado por se candidatar ", name);
                content = "Obrigado por se candidatar, assim que tivermos uma vaga disponível para programador Mobile entraremos em contato.";
                dictionary.Add(3, string.Concat(subject, "|", content));
            }

            if (!criterion)
            {
                subject = string.Concat("Obrigado por se candidatar ", name);
                content = "Obrigado por se candidatar, assim que tivermos uma vaga disponível para programador entraremos em contato.";
                dictionary.Add(4, string.Concat(subject, "|", content));
            }

            foreach (var item in dictionary)
            {
                List<string> stringList = new List<string>(item.Value.Split(new string[] { "|" }, StringSplitOptions.None));

                sucess = SendEmailToClient(email, stringList[0], stringList[1]);

                if (!sucess)
                    break;
            }

            if (!sucess)
                return false;
            else
                return true;
        }
开发者ID:thiagofriedmanfalcao,项目名称:RatingCandidate,代码行数:58,代码来源:HomeController.cs

示例6: ConnectData

    public object ConnectData(int topicId, ref Array Strings, ref bool GetNewValues)
    {
        m_source[topicId] = Strings.GetValue(0).ToString();
        m_bland[topicId] = Strings.GetValue(1).ToString();
        m_field[topicId] = Strings.GetValue(2).ToString();

        m_timer.Start();

        return "Data not found.";
    }
开发者ID:system-tradingtech,项目名称:DataTools,代码行数:10,代码来源:MarketDataDNA_RealTimeServer.cs

示例7: Shuffle

 public static void Shuffle(this Random rng, Array array)
 {
     int n = array.Length;
     while (n > 1) {
         int k = rng.Next (n--);
         object temp = array.GetValue (n);
         array.SetValue (array.GetValue (k), n);
         array.SetValue (temp, k);
     }
 }
开发者ID:dannisliang,项目名称:unity-tools-1,代码行数:10,代码来源:RandomExtensions.cs

示例8: AddToLog

 public void AddToLog(Array lines, int i, Color textColor)
 {
     rtbLogText.SelectionColor = textColor;
     rtbLogText.AppendText(string.Format("{0}{1}", lines.GetValue(i) as string, Environment.NewLine));
     fullRTFcode = rtbLogText.Rtf;
     if (textColor == Color.Red)
         subsetErrorRTFList.Add((string.Format("{0}{1}", lines.GetValue(i) as string, Environment.NewLine)));
     else if (textColor == Color.DarkCyan)
         subsetWarningRTFList.Add((string.Format("{0}{1}", lines.GetValue(i) as string, Environment.NewLine)));
     else if (textColor == ForeColor)
         subsetSubmittedRTFList.Add((string.Format("{0}{1}", lines.GetValue(i) as string, Environment.NewLine)));
 }
开发者ID:EmperorShmoo,项目名称:Project,代码行数:12,代码来源:LogWindow.cs

示例9: CompareObjects

 public static bool CompareObjects(Array obj1, Array obj2)
 {
     if (obj1 == null || obj2 == null) return false;
     string s;
     string y;
     for (int i = 0; i < obj1.Length; i++)
     {
         s = obj1.GetValue(i).ToString();
         y = obj2.GetValue(i).ToString();
         if (obj1.GetValue(i).ToString() != obj2.GetValue(i).ToString()) return false;
     }
     return true;
 }
开发者ID:d9d9,项目名称:sharp,代码行数:13,代码来源:Helper.cs

示例10: Equals

 public static void Equals(Array a, Array b, string message=null) {
     if(a.Length != b.Length)
         throw new AssertFailedException("A and B are not of equal length (" + a.Length + " != " + b.Length + ")");
     for(int i=0;i<a.Length;i++) {
         var ai = a.GetValue(i);
         var bi = b.GetValue(i);
         if(ai is IComparable && bi is IComparable) {
             Equals((IComparable)ai, (IComparable)bi, message);
         } else if(ai != bi){
             throw new AssertFailedException(String.IsNullOrEmpty(message) ? a.GetValue(i).ToString() + " != " + b.GetValue(i).ToString() : message);
         }
     }
 }
开发者ID:maka-io,项目名称:netcdf4.net,代码行数:13,代码来源:Assert.cs

示例11: SortGenericArray

        protected override void SortGenericArray(Array items, int left, int right)
        {
            int lo = left;
            int hi = right;

            if (lo >= hi)
            {
                return;
            }

            int mid = (lo + hi) / 2;

            // Partition the items into two lists and Sort them recursively
            SortGenericArray(items, lo, mid);
            SortGenericArray(items, mid + 1, hi);

            // Merge the two sorted lists
            int end_lo = mid;
            int start_hi = mid + 1;

            while ((lo <= end_lo) && (start_hi <= hi))
            {

                if (this.comparer.Compare(items.GetValue(lo), items.GetValue(start_hi)) < 0)
                {
                    lo++;
                }
                else
                {
                    /*
                  *  items[lo] >= items[start_hi]
                  *  The next element comes from the second items,
                  *  move the items[start_hi] element into the next
                  *  position and shuffle all the other elements up.
                  */
                    object T = items.GetValue(start_hi);

                    for (int k = start_hi - 1; k >= lo; k--)
                    {
                        items.SetValue(items.GetValue(k), k + 1);
                    }

                    items.SetValue(T, lo);
                    lo++;
                    end_lo++;
                    start_hi++;
                }
            }
        }
开发者ID:jihadbird,项目名称:firespider,代码行数:49,代码来源:MergeSorter.cs

示例12: AreEqual

        /// <summary>
        ///     Tests equality of two single-dimensional arrays by checking each element
        ///     for equality.
        /// </summary>
        /// <param name="a">The first array to be checked.</param>
        /// <param name="b">The second array to be checked.</param>
        /// <returns>True if arrays are the same, false otherwise.</returns>
        public static bool AreEqual(Array a, Array b)
        {
            if (a == null && b == null)
            {
                return true;
            }

            if (a != null && b != null)
            {
                if (a.Length == b.Length)
                {
                    for (var i = 0; i < a.Length; i++)
                    {
                        var elemA = a.GetValue(i);
                        var elemB = b.GetValue(i);

                        if (elemA is Array && elemB is Array)
                        {
                            if (!AreEqual(elemA as Array, elemB as Array))
                            {
                                return false;
                            }
                        }
                        else if (!Equals(elemA, elemB))
                        {
                            return false;
                        }
                    }
                    return true;
                }
            }
            return false;
        }
开发者ID:kog,项目名称:Solenoid-Expressions,代码行数:40,代码来源:ArrayUtils.cs

示例13: IsAssignableArrayFrom

        public static bool IsAssignableArrayFrom(this Array source, Array target)
        {
            if (source == null || target == null)
            {
                throw new ArgumentNullException("source");
            }

            if (source == target)
            {
                return true;
            }

            if (source.Length != target.Length)
            {
                return false;
            }

            int i = 0;
            while (i < source.Length)
            {
                if (source.GetType().IsAssignableFrom(target.GetValue(i).GetType()))
                {
                    return false;
                }

                i++;
            }

            return true;
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:30,代码来源:Array.cs

示例14: Array

			public static JavaObjectFactory Array(JniWrapper vm, Type dotNetType, Array prototype)
			{
				object innerPrototype = null;
				if (prototype != null && prototype.Length > 0)
				{
					innerPrototype = prototype.GetValue(0);
				}
				JavaObjectFactory innerFactory = GetJavaType(vm, dotNetType.GetElementType(), innerPrototype);
				ArrayType javaArrayType = new ArrayType(innerFactory.JavaType);
				return new JavaObjectFactory(o =>
					{
						Array asArray = (Array)o;
						PrimitiveType asPrimitive = javaArrayType.MemberType as PrimitiveType;
						if (asPrimitive != null)
						{
							switch (asPrimitive.Kind)
							{
								case PrimitiveTypeKind.Boolean: return vm.NewBooleanArray((bool[])o);
								case PrimitiveTypeKind.Byte: return vm.NewByteArray((byte[])o);
								case PrimitiveTypeKind.Char: return vm.NewCharArray((char[])o);
								case PrimitiveTypeKind.Double: return vm.NewDoubleArray((double[])o);
								case PrimitiveTypeKind.Float: return vm.NewFloatArray((float[])o);
								case PrimitiveTypeKind.Int: return vm.NewIntArray((int[])o);
								case PrimitiveTypeKind.Long: return vm.NewLongArray((long[])o);
								case PrimitiveTypeKind.Short: return vm.NewShortArray((short[])o);
								default: throw new InvalidOperationException("Unknown primitive kind: " + asPrimitive.Kind);
							}
						}
						else
						{
							IntPtr[] elements = asArray.Cast<object>().Select(innerFactory._factory).Select(v => v.ToIntPtr()).ToArray();
							return vm.NewArray(vm.FindClass(innerFactory.JavaType.JniClassName), elements);
						}
					}, javaArrayType);
			}
开发者ID:shimondoodkin,项目名称:DarkNotes,代码行数:35,代码来源:ParameterInfo.cs

示例15: Encode

 public static void Encode(LittleEndianOutput out1, Array values)
 {
     for (int i = 0; i < values.Length; i++)
     {
         EncodeSingleValue(out1, values.GetValue(i));
     }
 }
开发者ID:babywzazy,项目名称:Server,代码行数:7,代码来源:ConstantValueParser.cs


注:本文中的System.Array.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。