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


C# ArrayList.CopyTo方法代码示例

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


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

示例1: ReadLine

        /// <summary>
        /// Reads byte[] line from stream.
        /// </summary>
        /// <returns>Return null if end of stream reached.</returns>
        public byte[] ReadLine()
        {
            ArrayList lineBuf  = new ArrayList();
            byte      prevByte = 0;

            int currByteInt = m_StrmSource.ReadByte();
            while(currByteInt > -1){
                lineBuf.Add((byte)currByteInt);

                // Line found
                if((prevByte == (byte)'\r' && (byte)currByteInt == (byte)'\n')){
                    byte[] retVal = new byte[lineBuf.Count-2];    // Remove <CRLF>
                    lineBuf.CopyTo(0,retVal,0,lineBuf.Count-2);

                    return retVal;
                }

                // Store byte
                prevByte = (byte)currByteInt;

                // Read next byte
                currByteInt = m_StrmSource.ReadByte();
            }

            // Line isn't terminated with <CRLF> and has some chars left, return them.
            if(lineBuf.Count > 0){
                byte[] retVal = new byte[lineBuf.Count];
                lineBuf.CopyTo(0,retVal,0,lineBuf.Count);

                return retVal;
            }

            return null;
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:38,代码来源:StreamLineReader.cs

示例2: Add

 public void Add(string name, string fieldValue, bool readOnly)
 {
     ArrayList list = new ArrayList(this.SharePointListFields);
     list.Add(new SharePointListField(name, fieldValue, readOnly));
     this.sharePointListFields = new SharePointListField[list.Count];
     list.CopyTo(this.SharePointListFields);
 }
开发者ID:bsimser,项目名称:spforums,代码行数:7,代码来源:SharePointListItem.cs

示例3: GetValidationMethods

        /// <summary>
        /// Returns an array of any MethodInfo's on a Type that are marked as ValidationMethod
        /// </summary>
        /// <param name="objectType">CLR Type to search for validation methods</param>
        /// <returns></returns>
        public static MethodInfo[] GetValidationMethods(Type objectType)
        {
            var methodList = new ArrayList();

            MethodInfo[] methods = objectType.GetMethods();
            foreach (MethodInfo method in methods)
            {
                var att =
                    (ValidationMethodAttribute) GetCustomAttribute(method, typeof (ValidationMethodAttribute));

                if (att != null)
                {
                    if (method.GetParameters().Length > 0)
                    {
                        string msg =
                            string.Format(
                                "Method *{0}* in Class *{1}* cannot be a validation method because it has parameters",
                                method.Name, objectType.AssemblyQualifiedName);
                        throw new ApplicationException(msg);
                    }

                    methodList.Add(method);
                }
            }

            var returnValue = new MethodInfo[methodList.Count];
            methodList.CopyTo(returnValue, 0);

            return returnValue;
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:35,代码来源:ValidationMethodAttribute.cs

示例4: CopyTo

		public void CopyTo(Array array, int index)
		{
			ArrayList arrayList = new ArrayList();
			foreach (BrokerAccountField brokerAccountField in this)
				arrayList.Add((object)brokerAccountField);
			arrayList.CopyTo(array, index);
		}
开发者ID:heber,项目名称:FreeOQ,代码行数:7,代码来源:BrokerAccountFieldList.cs

示例5: GetAllUsers

        public static UserInfo[] GetAllUsers()
        {
            ArrayList al = new ArrayList();

            int retValue = -1;

            //Generated Code for query : dbo.GetAllVendors
            using (SqlDataReader dr = ProjManagementAdmin.GetAllUsers(out retValue)) //Initialize and retrieve code for Datareader goes here
            {

                while (dr.Read())
                {
                    UserInfo user = new UserInfo();

                    user.UserName = dr["user_name"].ToString();
                    user.UserId = Convert.ToInt32(dr["user_id"]);
                    user.UserEmail = dr["user_email"].ToString();
                    user.RoleId = Convert.ToInt32(dr["role_id"]);
                   // user.Password = Convert.ToChar(dr["password"]);
                    user.CreatedDate = Convert.ToDateTime(dr["created_date"]);
                    user.ChangedDate = Convert.ToDateTime(dr["changed_date"]);
                    user.ChangedBy = dr["changed_by"].ToString();

                    al.Add(user);
                }
                //dr.Close();
            }

            UserInfo[] allInfo = new UserInfo[al.Count];
            al.CopyTo(allInfo);
            return allInfo;
        }
开发者ID:sanyam43,项目名称:PMA-ISecG,代码行数:32,代码来源:UserDal.cs

示例6: InternalExecution

        //EXECUTION
        protected override void InternalExecution()
        {
            int size = 100;
            IList list = new ArrayList();

            IQuantumState newState;
            IQuantumOperator randomizer = QuantumOperatorFactory.generateRandomizeOperator();
            TesterLog("Generating " + size + " QuantumSimpleStates of 3 levels and initializing to random....");
            for (int i = 0; i < size; i++)
            {
                newState = QuantumStateFactory.generateStateSimple(3);
                randomizer.Evaluate(newState);
                list.Add(newState);
            }

            TesterLog("");
            TesterLog("Showing all of them");
            for (int i = 0; i < size; i++)
            {
                newState = (IQuantumState)list[i];
                TesterLog(newState.generateQuantumDebugger().FullDebug);
            }

            TesterLog("");
            TesterLog("Getting a composed state of all of them");
            IQuantumState[] array = new IQuantumState[list.Count];
            list.CopyTo(array,0);
            IQuantumState composed = QuantumStateFactory.generateStateComposed(array);
            TesterLog(composed.generateQuantumDebugger().FullDebug);
        }
开发者ID:fernandolucasrodriguez,项目名称:qit,代码行数:31,代码来源:ManyStates.cs

示例7: Main

 static void Main(string[] args)
 {
     ArrayList al = new ArrayList();
     al.Add("string");
     al.Add('B');
     al.Add(10);
     al.Add(DateTime.Now);
     ArrayList bl = new ArrayList(5);
     al.Remove('B');
     // 从al中删除第一个匹配的对象,如果al中不包含该对象,数组保持不变,不引发异常。
     al.Remove('B');
     al.RemoveAt(0);
     al.RemoveRange(0, 1);
     bl.Add(1);
     bl.Add(11);
     bl.Add(111);
     bl.Insert(4, 1111);
     int[] inttest = (int[])bl.ToArray(typeof(int));
     foreach(int it in inttest)
         Console.WriteLine(it);
     int[] inttest2 = new int[bl.Count];
     bl.CopyTo(inttest2);
     ArrayList cl = new ArrayList();
     cl.Add(1);
     cl.Add("Hello, World!");
     object[] ol = (object[])cl.ToArray(typeof(object));
     // stringp[] os = (string[])cl.ToArray(typeof(string));
     Console.WriteLine("The Capacity of new ArrayList: {0}", al.Capacity);
 }
开发者ID:ZLLselfRedeem,项目名称:zllinmitu,代码行数:29,代码来源:Program.cs

示例8: OracleDataReader

 internal OracleDataReader(OracleCommand command, ArrayList refCursorParameterOrdinals, string statementText, CommandBehavior commandBehavior)
 {
     this.ObjectID = Interlocked.Increment(ref _objectTypeCount);
     this._commandBehavior = commandBehavior;
     this._statementText = statementText;
     this._closeConnectionToo = this.IsCommandBehavior(CommandBehavior.CloseConnection);
     if (CommandType.Text == command.CommandType)
     {
         this._keyInfoRequested = this.IsCommandBehavior(CommandBehavior.KeyInfo);
     }
     ArrayList list = new ArrayList();
     int num2 = 0;
     OracleDataReader reader = null;
     for (int i = 0; i < refCursorParameterOrdinals.Count; i++)
     {
         int num3 = (int) refCursorParameterOrdinals[i];
         OracleParameter parameter = command.Parameters[num3];
         if (OracleType.Cursor == parameter.OracleType)
         {
             reader = (OracleDataReader) parameter.Value;
             reader._recordsAffected = num2;
             list.Add(reader);
             parameter.Value = DBNull.Value;
         }
         else
         {
             num2 += (int) parameter.Value;
         }
     }
     this._refCursorDataReaders = new OracleDataReader[list.Count];
     list.CopyTo(this._refCursorDataReaders);
     this._nextRefCursor = 0;
     this.NextResultInternal();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:OracleDataReader.cs

示例9: LadeEtbEintraege

        /// <summary>
        /// Diese Funktion gibt alle EtbEintraege zurueck, die nicht Systemereignisse sind.
        /// </summary>
        /// <returns>Menge aller EtbZusatzeintraege</returns>
        public Cdv_EtbEintrag[] LadeEtbEintraege()
        {
            // hole alle EtbEintraege
            pELS.DV.Server.Interfaces.IPelsObject[] ipoa = _ObjektManager.EtbEintraege.HolenAlle();
            if(!(ipoa == null) || (ipoa.Length == 0))
            {
                Cdv_EtbEintrag[] tmpEtbEintraege = new Cdv_EtbEintrag[ipoa.Length];
                ipoa.CopyTo(tmpEtbEintraege,0);

                //Schmeiße alle Systemereignisse raus
                ArrayList _tmpAL = new ArrayList();
                for (int pos = 0; pos < tmpEtbEintraege.Length; pos++)
                {
                    if (tmpEtbEintraege[pos].GetType().ToString() != "pELS.DV.Cdv_Systemereignis") _tmpAL.Add(tmpEtbEintraege[pos]);
                }

                // kopiere Einträge aus ArrayList nach Array
                Cdv_EtbEintrag[] pout_EtbEintraege = new Cdv_EtbEintrag[_tmpAL.Count];
                _tmpAL.CopyTo(pout_EtbEintraege);

                //nach Datum sortieren
                pout_EtbEintraege = this.SortiereNachDatum(pout_EtbEintraege);
                return pout_EtbEintraege;
            }
            else
                return null;
        }
开发者ID:BackupTheBerlios,项目名称:pels-svn,代码行数:31,代码来源:PortalLogik_ETB.cs

示例10: ForceDirectedLayout

        /// <summary>
        /// Initializes this force-directed layout. Assumes that graph has some
        /// reasonable initial node positions.
        /// </summary>
        /// <param name="graph">The graph to layout.</param>
        /// <param name="start_node">The node to start layout from.</param>
        public ForceDirectedLayout(IReadOnlyGraph<FDLNode, FDLEdge> graph, FDLNode start_node)
        {
            if (graph == null)
                throw new ArgumentNullException("graph");
            if (start_node == null)
                throw new ArgumentNullException("start_node");
            if (!graph.ContainsNode(start_node))
                throw new ArgumentException("start_node must be in this graph");

            //initialize nodes array to only the reachable nodes
            ArrayList n = new ArrayList(graph.NodeCount);
            Algorithms.Algorithms.BreadthFirstSearch(graph, start_node, null, delegate(FDLNode node){
                n.Add(node);
            });
            nodes = new FDLNode[n.Count];
            n.CopyTo(nodes);

            new_positions = new MutablePoint[nodes.Length];
            accels = new double[nodes.Length];

            //summarize constraints
            HashSet<FDLEdge> h = new HashSet<FDLEdge>();
            for (int i = 0; i < nodes.Length; i++)
            {
                foreach (FDLEdge edge in nodes[i].OutEdges)
                {
                    DefaultEdge reverse = edge.Target.GetEdgeTo(edge.Source);
                    if(h.Contains(edge) || (reverse != null && h.Contains(reverse)))
                        continue;
                    h.Add(edge);
                }
            }
            constraints = new FDLEdge[h.Count];
            h.CopyTo(constraints);
        }
开发者ID:sooniln,项目名称:angle_constrained_fdl,代码行数:41,代码来源:ForceDirectedLayout.cs

示例11: GetAllBeneficiaries

        public static BeneficiaryProjLocInfo[] GetAllBeneficiaries()
        {
            ArrayList al = new ArrayList();
            int retValue = -1;
            //Generated Code for query : dbo.GetAllVendors
            using (SqlDataReader dr = ProjManagementAdmin.GetAllBeneficiaries(out retValue)) //Initialize and retrieve code for Datareader goes here
            {

                while (dr.Read())
                {
                    BeneficiaryProjLocInfo b = new BeneficiaryProjLocInfo();
                    b.BeneficiaryId = Convert.ToInt32(dr["beneficiary_id"]);
                    b.BeneficiaryName = dr["beneficiary_name"].ToString();
                    b.BeneficiaryAddress = dr["beneficiary_address"].ToString();
                    b.ProjectLocationId = Convert.ToInt32(dr["project_location_id"]);
                    b.ProjectId = Convert.ToInt32(dr["project_id"]);
                   b.ProjectName = dr["project_name"].ToString();
                    // b.ProjectCode = dr["project_code"].ToString();

                    b.LocationId = Convert.ToInt32(dr["location_id"]);
                    b.LocationName = dr["location_name"].ToString();

                    b.IsActive = Convert.ToBoolean(dr["is_active"]);
                    b.CreatedDate = Convert.ToDateTime(dr["created_date"]);
                    b.ChangedDate = Convert.ToDateTime(dr["changed_date"]);
                    b.ChangedBy = dr["changed_by"].ToString();
                    al.Add(b);
                }
                //dr.Close();
            }

            BeneficiaryProjLocInfo[] allInfo = new BeneficiaryProjLocInfo[al.Count];
            al.CopyTo(allInfo);
            return allInfo;
        }
开发者ID:nehason,项目名称:PMA-ISecG,代码行数:35,代码来源:BeneficiaryProjLocDal.cs

示例12: GetAllLocations

        public static LocationInfo[] GetAllLocations()
        {
            ArrayList al = new ArrayList();

            int retValue = -1;

            //Generated Code for query : dbo.GetAllVendors
            using (SqlDataReader dr = ProjManagementAdmin.GetAllLocations(out retValue)) //Initialize and retrieve code for Datareader goes here
            {

                while (dr.Read())
                {
                    LocationInfo location = new LocationInfo();
                    location.LocationId = Convert.ToInt32(dr["location_id"]);
                    location.LocationName = dr["location_name"].ToString();
                    location.CreatedDate = Convert.ToDateTime(dr["created_date"]);
                    location.ChangedDate = Convert.ToDateTime(dr["changed_date"]);
                    location.ChangedByName = dr["changed_by"].ToString();
                    al.Add(location);
                }
                //dr.Close();
            }

            LocationInfo[] allInfo = new LocationInfo[al.Count];
            al.CopyTo(allInfo);
            return allInfo;
        }
开发者ID:nehason,项目名称:PMA-ISecG,代码行数:27,代码来源:LocationDal.cs

示例13: TryConvert

        public bool TryConvert(ConvertArgs args)
        {
            if (!args.DestinationType.IsArray)
            {
                return false;
            }
            if (args.Reader.Value == null)
            {
                args.ConvertedObject = null;
                return true;
            }

            ArrayList arrayList = new ArrayList();
            var elementType = args.DestinationType.GetElementType();
            var enumerableItems = args.Reader.Value as IEnumerable;
            if (enumerableItems == null)
            {
                return true;
            }
            foreach (var obj in enumerableItems)
            {
                Type toElementType = args.Converter.GetDestinationType(obj, elementType);
                var dstObject = args.Converter.MapObject(obj, toElementType);
                arrayList.Add(dstObject);
            }
            var array = (Array)Activator.CreateInstance(args.DestinationType, new object[] { arrayList.Count });
            arrayList.CopyTo(array);
            args.ConvertedObject = array;
            return true;
        }
开发者ID:yangwen27,项目名称:moonlit,代码行数:30,代码来源:ArrayObjectConverter.cs

示例14: SaveButton_Click

 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (SubjectBox.Text.Length == 0)
     {
         MessageBox.Show("Cannot proceed with empty name");
         return;
     }
     ArrayList list = new ArrayList((string[])Host.SubjectList.DataSource);
     list.Sort();
     int id = list.BinarySearch(SubjectBox.Text);
     if (id >= 0)
     {
         MessageBox.Show("Subject with that name already exists!");
         return;
     }
     id = ~id;
     list.Insert(id, SubjectBox.Text);
     string[] n = new string[list.Count];
     list.CopyTo(n);
     Host.SubjectBox2.AutoCompleteCustomSource.Add(SubjectBox.Text);
     Host.SubjectList.DataSource = n;
     Host.RenewSubjectList();
     Host.SubjectList.SelectedItem = SubjectBox.Text;
     this.Close();
 }
开发者ID:Hikari9,项目名称:ScheduleMaster,代码行数:25,代码来源:AddSubjectForm.cs

示例15: Split

        /// <summary>
        /// Split Function that Supports Text Qualifiers
        /// Source: http://www.codeproject.com/KB/dotnet/TextQualifyingSplit.aspx
        /// </summary>
        private static string[] Split(string expression, string delimiter, string qualifier, bool ignoreCase)
        {
            bool qualifierState = false;
            int startIndex = 0;
            ArrayList values = new ArrayList();

            for (int charIndex = 0; charIndex < expression.Length - 1; charIndex++)
            {
                if ((qualifier != null)
                 & (string.Compare(expression.Substring(charIndex, qualifier.Length), qualifier, ignoreCase) == 0))
                {
                    qualifierState = !(qualifierState);
                }
                else if (!(qualifierState) & (delimiter != null)
                      & (string.Compare(expression.Substring(charIndex, delimiter.Length), delimiter, ignoreCase) == 0))
                {
                    values.Add(expression.Substring(startIndex, charIndex - startIndex));
                    startIndex = charIndex + 1;
                }
            }

            if (startIndex < expression.Length)
                values.Add(expression.Substring(startIndex, expression.Length - startIndex));

            string[] returnValues = new string[values.Count];
            values.CopyTo(returnValues);
            return returnValues;
        }
开发者ID:dbremner,项目名称:DotNetNinjaQuiz,代码行数:32,代码来源:QuestionFactory.cs


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