1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

C# beginner

Discussion in 'C#' started by yibman, May 6, 2006.

  1. yibman

    yibman New Member

    Joined:
    May 6, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi i am a beginner in c# programming. Can Anybody tell me what happens in the code lines for this class :
    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections.ObjectModel;
    using System.Diagnostics;
    using System.Reflection;
    
    namespace WindowsApplication3.Data
    {
        public class LogEntryCollection : ObjectCollection<LogEntry>
        {
            private DataObject owner;
            public DataObject Owner 
            {
                get { return this.owner; }
            }
    
            protected override void InsertItem(int index, LogEntry item)
            {
                LogEntry le = new LogEntry(this.owner);
                le.Text = item.Text;
                le.Time = item.Time;
                item = le;
    
                base.InsertItem(index, item);
            }
    
            public void Persist()
            {
                DataManager.Current.Engine.PersistChanges(this);
            }
    
            public LogEntryCollection(DataObject owner)
            {
                this.owner = owner;
            }
    
            public LogEntry[] Sort()
            {
                LogEntry[] coll = new LogEntry[this.Count];
                this.CopyTo(coll, 0);
    
                for (int i = 0; i < coll.Length - 1; i++)
                {
                    for (int j = 0; j < coll.Length - 1 - i; j++)
                    {
                        if (coll[j + 1].Time.CompareTo(coll[j].Time) > 0)
                        {
                            Swap(ref coll[j], ref coll[j + 1]);
                        }
                    }
                }
    
                return coll;
            }
    
            private static void Swap(ref LogEntry le1, ref LogEntry le2)
            {
                LogEntry tmp = le2;
                le2 = le1;
                le1 = tmp;
            }
        }
    }
     
    Last edited by a moderator: May 7, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    It logs the necessary data through the LogEntry class.
     

Share This Page