Tag Archives: methods

Make generic Min and Max methods in C#

This example shows how you can make generic Min and Max methods to find the minimum and maximum values in a sequence of parameters. The Math namespace’s Min and Max methods are very useful, but they have two big drawbacks. … Continue reading

Posted in algorithms, arrays, calculations, generic, methods | Tagged , , , , , , , , , , , , , , | Leave a comment

Get the executing method name in C#

This example shows how you can get the method name for the currently executing method. Normally you don’t need to get that name (you can just look at the code you’re typing), but sometimes it’s useful for standard tracing and … Continue reading

Posted in debugging, Uncategorized | Tagged , , , , , , , , , | Leave a comment

Let controls share event handlers in C#

Sometimes it would be useful to let controls share event handlers. Often a program has several controls that do almost the same thing. It would be nice if they could share the same event handler to increase code reuse, but … Continue reading

Posted in controls, methods | Tagged , , , , , , , , , , , , | Leave a comment

Use the params keyword in C#

If you use the params keyword before an array parameter used as the last parameter in a method, then the calling code can pass any number of values for that parameter. The following code defines a ShowValues method that can … Continue reading

Posted in methods | Tagged , , , , , , , , , , , | 4 Comments