// Bind late to a method taking params.
object[] paramArray = new object[2];
paramArray[0] = "Fred"; // Child name.
paramArray[1] = 4; // Shame Intensity.
mi = miniVan.GetMethod("TellChildToBeQuiet");
mi.Invoke(obj, paramArray);
Console.ReadLine();
}
If you run this program, you will see four message boxes pop up, shaming young Fred. Hope-
fully at this point you can see the relationships among reflection, dynamic loading, and late binding.
Again, you still may wonder exactly
when you might make use of these techniques in your own
applications. The conclusion of this chapter should shed light on this question; however, the next
topic under investigation is the role of .NET attributes.
Do'stlaringiz bilan baham: |