Example #1
0
        public static List <T> WhereLeast <T>(this List <T> l, IntegerDelegate <T> value)
        {
            List <T> result = new List <T>();
            int      lowest = 0;
            bool     first  = true;

            foreach (T t in l)
            {
                int i = value(t);
                if (first)
                {
                    first  = false;
                    lowest = i;
                    result.Add(t);
                }
                else
                {
                    if (i < lowest)
                    {
                        lowest = i;
                        result.Clear();
                        result.Add(t);
                    }
                    else
                    {
                        if (i == lowest)
                        {
                            result.Add(t);
                        }
                    }
                }
            }
            return(result);
        }
Example #2
0
        static void Main(string[] args)
        {
            //Print the Max,Min,Average Array Values
            int[]           MaxMinAve     = { 5, 10, 21, 35, 23 };
            int             max           = MaxMinAve[0];
            int             min           = MaxMinAve[0];
            double          sum           = 0;
            IntegerDelegate maxMinAverage = () => {
                foreach (int num in MaxMinAve)
                {
                    sum += num;
                    if (num > max)
                    {
                        max = num;
                    }
                    if (min > num)
                    {
                        min = num;
                    }
                }
                double average = sum / (double)MaxMinAve.Length;
                Console.WriteLine("The maximum is " + max);
                Console.WriteLine("The minimum is " + min);
                Console.WriteLine("The average is " + average);
            };

            maxMinAverage();
        }
Example #3
0
        static void Main(string[] args)
        {
            //Swap string for array negative value
            // ArrayList SwapString = new ArrayList() {3,-4,5,6,-8,-1};
            // IntegerDelegate ArrayNegative = () => {
            //     for(int i = 0; i < SwapString.Count; i++){
            //         if((int)SwapString[i] < 0){
            //             SwapString[i] = "Codebits";
            //         }
            //         Console.Write(SwapString[i] + ",");
            //     }
            // };
            // ArrayNegative();

            ArrayList SwapString = new ArrayList()
            {
                3, -4, 5, 6, -8, -1
            };
            IntegerDelegate ArrayNegative = (Swapstring) => {
                for (int i = 0; i < SwapString.Count; i++)
                {
                    if ((int)SwapString[i] < 0)
                    {
                        SwapString[i] = "Codebits";
                    }
                    Console.Write(SwapString[i] + ",");
                }
            };

            ArrayNegative(SwapString);
        }
Example #4
0
 private void lSocket_socketConnected(string socketID)
 {
     try {
         IntegerDelegate connectEvent = new IntegerDelegate(lStatus.ConnectEvent);
         _invoke.Invoke(connectEvent, statusId);
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #5
0
 private void _clientSocket_DataArrival(string data)
 {
     try {
         var             statusId = lStatus.ActiveIndex();
         IntegerDelegate processSocketDataArrivalProc = new IntegerDelegate(ProcessSocketDataArrival);
         lStatus.GetObject(statusId).sWindow.Invoke(processSocketDataArrivalProc, statusId);
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #6
0
        static void Main(string[] args)
        {
            //Print 1 - 255
            IntegerDelegate integerDelegate = () => {
                for (int i = 1; i <= 255; i++)
                {
                    Console.Write(i + ",");
                }
            };

            integerDelegate();
        }
Example #7
0
        static void Main(string[] args)
        {
            //Iterate through an array and print all its value
            int[]           iterate   = { 66, 2, 34, 12, 45, 62 };
            IntegerDelegate iteration = () => {
                foreach (int num in iterate)
                {
                    Console.Write(num + ",");
                }
            };

            iteration();
        }
Example #8
0
        static void Main(string[] args)
        {
            // Square each num in an array
            int[]           squareNum = { 6, 2, 4, 2, 5, 8 };
            IntegerDelegate NumSquare = () => {
                for (int i = 0; i < squareNum.Length; i++)
                {
                    squareNum[i] = squareNum[i] * squareNum[i];
                    Console.Write(squareNum[i] + ",");
                }
            };

            NumSquare();
        }
Example #9
0
        static void Main(string[] args)
        {
            //Print int and sum 0-255
            IntegerDelegate intAndSum = () => {
                int a = 0;
                for (int i = 0; i <= 255; i++)
                {
                    a += i;
                    Console.Write(i + " sum = " + a + ", ");
                }
            };

            intAndSum();
        }
Example #10
0
        static void Main(string[] args)
        {
            //Print average
            int[]           getaverage     = { 66, 2, 34, 12, 45, 62 };
            IntegerDelegate gettingAverage = () => {
                double a = 0;
                foreach (int num in getaverage)
                {
                    a += (double)num;
                }
                Console.Write(a / getaverage.Length);
            };

            gettingAverage();
        }
Example #11
0
        static void Main(string[] args)
        {
            //Print all Odd numbers from 1 - 255
            IntegerDelegate Oddnum = () => {
                for (int i = 1; i <= 255; i++)
                {
                    if (i % 2 != 0)
                    {
                        Console.Write(i + ",");
                    }
                }
            };

            Oddnum();
        }
Example #12
0
        static void Main(string[] args)
        {
            //Zero out array negative number
            int[]           ArrNeg     = { -6, 2, -4, 2, -5, 8 };
            IntegerDelegate ZeroNegNum = () => {
                for (int i = 0; i < ArrNeg.Length; i++)
                {
                    if (ArrNeg[i] < 0)
                    {
                        ArrNeg[i] = 0;
                    }
                    Console.Write(ArrNeg[i] + ",");
                }
            };

            ZeroNegNum();
        }
Example #13
0
        static void Main(string[] args)
        {
            //Print Max of Array
            int[]           arr         = new int[] { 13, 55, 7, 19, 65, 12, 34 };
            IntegerDelegate arrDelegate = () => {
                int b = 0;
                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i] >= b)
                    {
                        b = arr[i];
                    }
                }
                Console.Write(b);
            };

            arrDelegate();
        }
Example #14
0
        static void Main(string[] args)
        {
            //Return Odd Array 1-255
            int[]           OddArray = new int[128];
            int             i;
            int             num    = 0;
            IntegerDelegate OddArr = () => {
                for (i = 1; i <= 255; i++)
                {
                    if (i % 2 != 0)
                    {
                        OddArray[num] = i;
                        Console.Write(OddArray[num] + ",");
                        num++;
                    }
                }
            };

            OddArr();
        }
Example #15
0
 public void InitializeCandExamCtrlComponent(ExamCtrlPanel examCtrl, CSettings settings, List <string> cxList)
 {
     this.examCtrl = examCtrl;
     this.examCtrl.OnChangeState += new ExamCtrlPanelEvent(this.examCtrl_stateChange);
     this.settings = settings;
     if (this.settings.PrintConfig.Isprint)
     {
         _printContent = new CPrintContent(this.settings.PrintConfig);
     }
     if (cxList != null)
     {
         _cxList = cxList;
     }
     else
     {
         _cxList = new List <string>(1);
     }
     this.SoundChange         += new MessageDelegate(OnSoundChange);
     this.LEDDisplayChange    += new MessageDelegate(OnLEDDisplayChange);
     this.CameraChannelChange += new IntegerDelegate(OnCameraChannelChange);
     this.ExamResultReady     += new ExamResultDelegate(OnExamResultReady);
     ResetPanel();
 }
Example #16
0
        static void Main(string[] args)
        {
            //Shift Array values left
            int[]           ArrShift   = { 2, 5, 4, 7, 1, 8 };
            IntegerDelegate ShiftArray = () => {
                int count = 1;
                for (int i = 0; i < ArrShift.Length; i++)
                {
                    if (count == ArrShift.Length)
                    {
                        ArrShift[i] = 0;
                    }
                    else
                    {
                        ArrShift[i] = ArrShift[i + 1];
                    }

                    Console.Write(ArrShift[i] + ",");
                    count++;
                }
            };

            ShiftArray();
        }
Example #17
0
 private void _clientSocket_DataArrival(string data)
 {
     try {
         var statusId = lStatus.ActiveIndex();
         IntegerDelegate processSocketDataArrivalProc = new IntegerDelegate(ProcessSocketDataArrival);
         lStatus.GetObject(statusId).sWindow.Invoke(processSocketDataArrivalProc, statusId);
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #18
0
 private void lSocket_socketConnected(string socketID)
 {
     try {
         IntegerDelegate connectEvent = new IntegerDelegate(lStatus.ConnectEvent);
         _invoke.Invoke(connectEvent, statusId);
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #19
0
 public void OnDestroy()
 {
     OnDone    = null;
     OnLevelUp = null;
 }