1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Common
- {
- public static class OtherHelper
- {
-
-
-
-
- public static Stopwatch SwStart()
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- return sw;
- }
-
-
-
-
-
- public static double SwStop(this Stopwatch sw)
- {
- sw.Stop();
- return sw.ElapsedMilliseconds;
- }
- public delegate void DelegateSw();
-
-
-
-
-
- public static double Sw(DelegateSw delegateSw)
- {
- var sw = SwStart();
- delegateSw();
- return sw.SwStop();
- }
-
-
-
-
-
-
- public static IEnumerable<int> RandomInt(int x, int[] array,List<int> list)
- {
- if (array.Length != 2)
- yield break;
- for (int i = 0; i < x; i++)
- {
- var ra = new Random(Guid.NewGuid().GetHashCode());
- var content = ra.Next(array[0], array[1] + 1);
- while (list.Contains(content))
- {
- content = ra.Next(array[0], array[1] + 1);
- }
- yield return content;
- }
- }
- }
- }
|