ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

Squared

Returns the squared value

Source

namespace Extensions
{
   public static class IntExtensions
   {
      public static int Squared(this int intToBeSquared)
      {
         return intToBeSquared * intToBeSquared;
      }
   }
}

Example

int result = 5.Squared();

Author: unknown

Submitted on: 24 jan 2008

Language: C#

Type: System.Int32

Views: 5142