Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Starting out with Visual Studio 2008-Need data access ad
Message
De
22/08/2009 16:19:00
 
 
À
22/08/2009 15:50:19
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Database:
Visual FoxPro
Divers
Thread ID:
01419709
Message ID:
01419852
Vues:
59
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform