What is the purpose of List?

It is possible that this method signature was created as a by-product of some generic class. For example, SwingWorker has two type parameters, one for final result and one for intermediate results. If you just don’t want to use any intermediate results, you pass Void as the type parameter, resulting in some methods returning Void … Read more

Await an async void method call for unit testing

You should avoid async void. Only use async void for event handlers. DelegateCommand is (logically) an event handler, so you can do it like this: // Use [InternalsVisibleTo] to share internal methods with the unit test project. internal async Task DoLookupCommandImpl(long idToLookUp) { IOrder order = await orderService.LookUpIdAsync(idToLookUp); // Close the search IsSearchShowing = false; … Read more

Why does C# not allow me to call a void method as part of the return statement?

Because it’s simply the way the language is defined. A method can use return statements to return control to its caller. In a method returning void, return statements cannot specify an expression. In a method returning non-void, return statements must include an expression that computes the return value. It’s an arbitrary decision (presumably made for … Read more

What is System.Void?

From the documentation: The Void structure is used in the System.Reflection namespace, but is rarely useful in a typical application. The Void structure has no members other than the ones all types inherit from the Object class. There’s no reason really to use it in code. Also: var nothing = new void(); This doesn’t compile … Read more

How to delete void pointer?

This as written is legal. The cast back to MyCls* is critical. Without that, you will invoke undefined behavior–the MyCls destructor will not be called, and other problems may arise as well (such as a crash). You must cast back to the correct type. Also note that this can be complicated if multiple inheritance is … Read more