Tham khảo tài liệu 'c# bible 2002 phần 3', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | array in a method parameter list however it must be specified as the last parameter in the list. You cannot use the out or ref keywords on a parameter array. Overloading Methods C enables you to define multiple methods with the same name in the same class as long as those methods have different parameter lists. This is referred to as overloading the method name. See Listing 6-9 for an example. Listing 6-9 Working with Overloaded Methods class Listing6 9 public static void Main Listing6 9 MyObject MyObject new Listing6 9 3 4 void Add int Integer1 int Integer2 int Sum adding two integers Sum Integer1 Integer2 Sum void Add double Double1 double Double2 double Sum adding two doubles Sum Double1 Double2 Sum Listing 6-9 implements two Add methods. One of the Add method takes two integers as input parameters and the other takes two doubles as input parameters. Because the two implementations have different parameter lists C allows the two Add methods to coexist in the same class. The Main method calls the Add method twice once with two integer parameter values and once with two floating-point values. As you can see in Figure 6-8 both methods run successfully processing the correct data. Figure 6-8 The overloaded method adds integers and doubles. When the C compiler encounters a call to a method that has more than one implementation it looks at the parameters used in the call and calls the method with the parameter list that best matches the parameters used in the call. Two integers are used in the first call to Add . The C compiler then matches this call up with the implementation of Add that takes the two integer input parameters because the parameters in the call match the parameter list with the integers. Two doubles are used in the second call to Add . The C compiler then matches this call up with the implementation of Add that takes .