Function names must be the same to form function overloads;
function return value type: can be the same or different (note: The return type of the function is not sufficient to distinguish two overloaded functions);
Function parameter type: must be different;
Number of function arguments: can be the same, can be different
function parameter order: can be the same, can be different;
Example: A point on the center of a known circle and a circular edge
public static double area (int x1, int y1, int x2, int y2)
{
int x = x2-x1;int y = y2-y2;double r = (double) math.s QRT (X*x+y*y); Console.WriteLine ("This is a circle in the circle ({0},{1}), around the circle ({2},{3}), the radius of the circle is {4}", x1,y1,x2,y2,r); return area (R);} static void Main (string[] args) {int x1=2,x2=4; x-coordinate int y1=3,y2=5; Y-coordinate double radius=3; Radius double circlearea = 0; Circlearea = Area (); Console.WriteLine ("-->1. Area of {0}", Circlearea); Console.WriteLine (); Circlearea = Area (x1,y1); Console.WriteLine ("-->2. Area of {0}", Circlearea); Console.WriteLine (); Circlearea = Area (RADIUS); Console.WriteLine ("-->3. Area of {0}", Circlearea); Console.WriteLine (); Circlearea = Area (x1, y1, radius); Console.WriteLine ("-->4. Area of {0}", Circlearea); Console.WriteLine (); Circlearea = Area (x1, y1, x2, y2); Console.WriteLine ("-->5. Area of {0}", Circlearea); Console.WriteLine (); Console.ReadLine (); }
C # function overloading