Tag Archives: C# programming

Use statement lambdas in C#

The example Use lambda expressions in C# showed how to use lambda expressions to concisely create an anonymous method that takes parameters and returns a value. The following code shows one of the lambda expressions that example used. private void … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Use lambda expressions in C#

Lambda expressions are basically just a shorthand notation for making an anonymous method. There are a couple of formats, the simplest of which has the following syntax. x => expression Here expression is an expression involving the variable x. For … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , , , | 1 Comment

Use anonymous methods in C#

My previous post Use the predefined Action, Func, and EventHandler delegate types in C# explains how to use the predefined generic Func, Action, and EventHandler delegate types to graph four functions F(x, y). It uses the following code to define … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , | 1 Comment

Use the predefined Action, Func, and EventHandler delegate types in C#

This and the next couple of posts discuss delegates and the somewhat related topics of anonymous methods and lambda expressions. Briefly, delegate types are programmer-defined data types that represent methods. For example, the following code declares a delegate type. // … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , | 1 Comment

A quick note on error messages

I went to a local museum the other day and when the attendant scanned by membership card his computer said: Object not set to a reference of an object. Because we’re programmers, you and I know what that means (more … Continue reading

Posted in MessageBox, miscellany, user interface | Tagged , , , , , , , , , , , , , | 1 Comment

Make a button display the picture beneath slightly grayed it in C#

The example Make a button display the picture beneath it in C# shows how to make a button display the picture that lies below it. Unfortunately, the button only adds a border as decoration and the border doesn’t have a … Continue reading

Posted in controls, graphics, image processing | Tagged , , , , , , , , , , , , | Leave a comment

Make a button display the picture beneath it in C#

This example makes a button display copies of the picture on which it sits, making it appear that the button is part of the underlying image. The key to this example is the following SetButtonBackground method. // Make the Button … Continue reading

Posted in controls, graphics, image processing | Tagged , , , , , , , , , , , , | 1 Comment

Validate optional parameters in C#

The example Use named and optional parameters in C# explains how to use named and optional parameters to let the calling code omit any combination of parameters. In many applications, you may not want to allow the user to omit … Continue reading

Posted in methods, syntax, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Use named and optional parameters in C#

Optional parameters is one of the few additions in recent versions of Visual Studio that are really useful. I usually try to post examples in an older version of C# because it’s easier for someone to move an older example … Continue reading

Posted in methods, syntax, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Display system metric values with descriptions in C#

The example Get system metrics in C# shows how to get system metrics, but the the metrics’ terse names make the results hard to understand. This example displays descriptions of the metrics in addition to their values. Some of the … Continue reading

Posted in API, system | Tagged , , , , , , , , , , , , , , | Leave a comment