C# numeric enum value as string

You should just be able to use the overloads of Enums ToString method to give it a format string, this will print out the value of the enum as a string. public static class Program { static void Main(string[] args) { var val = Urgency.High; Console.WriteLine(val.ToString(“D”)); } } public enum Urgency { VeryHigh = 1, … Read more

Return multiple values from a Java method: why no n-tuple objects?

I assume the OP means “Why does Java not support n-tuple objects?”. Python, Haskell, Lisp, ML etc have heterogeneous n-tuple capabilities. Also often times the ability to apparently return multiple objects in a language is syntactical sugar (ie in python return ‘a’,’b’). The reason of course is language design and consistency. Java prefers being very … Read more

Simplest way to determine return type of function

You can leverage std::function here which will give you an alias for the functions return type. This does require C++17 support, since it relies on class template argument deduction, but it will work with any callable type: using ReturnTypeOfFoo = decltype(std::function{foo})::result_type; We can make this a little more generic like template<typename Callable> using return_type_of_t = … Read more

What’s the difference between returning void and returning a Task?

SLaks and Killercam’s answers are good; I thought I’d just add a bit more context. Your first question is essentially about what methods can be marked async. A method marked as async can return void, Task or Task<T>. What are the differences between them? A Task<T> returning async method can be awaited, and when the … Read more