Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Starting out with Visual Studio 2008-Need data access ad
Message
From
22/08/2009 16:19:00
 
 
To
22/08/2009 15:50:19
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
C# 3.0
OS:
Vista
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01419709
Message ID:
01419852
Views:
60
>That may make sense, but Static classes should not be used everywhere.
>
>>To avoid too many extension methods. I have a static Arithmetic class, like Math

please define 'everywhere'


I use them either to group related functions or 'generic'

Oh - and before you ask - the pieces are in different files


example of generic
	public static partial class GenericBits
	{
		//______________________________________________________________________
		public static void Swap<T>(ref T x, ref T y)
		{
			T tmp = x; x = y; y = tmp;
		}
		//______________________________________________________________________
	}


	public static partial class GenericBits
	{
		//______________________________________________________________________
		/// <summary>
		/// returns the minimum
		/// </summary>
		/// <param name="list"></param>
		/// <returns></returns>
		public static T Min<T>(params T[] array) where T : IComparable<T>
		{
			var min = array[0];

			for (int i = array.Length; --i > 0; )
				if (min.CompareTo(array[i]) > 0)
					min = array[i];

			return min;
		}
		//______________________________________________________________________
	}

	public static partial class GenericBits
	{
		//______________________________________________________________________
		/// <summary>
		/// returns the maximum
		/// </summary>
		/// <param name="list"></param>
		/// <returns></returns>
		public static T Max<T>(params T[] array) where T : IComparable<T>
		{
			var max = array[0];

			for (int i = array.Length; --i > 0; )
				if (max.CompareTo(array[i]) < 0)
					max = array[i];

			return max;
		}
		//______________________________________________________________________
	}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform