What causes “extension methods cannot be dynamically dispatched” here?

So, can somebody please help me understand why leveraging the same overload inside of those other methods is failing with that error? Precisely because you’re using a dynamic value (param) as one of the arguments. That means it will use dynamic dispatch… but dynamic dispatch isn’t supported for extension methods. The solution is simple though: … Read more

How can you compare two character strings statically at compile time

Starting with C++17 std::string_view is available. It supports constexpr comparisson: #include <string_view> constexpr bool strings_equal(char const * a, char const * b) { return std::string_view(a)==b; } int main() { static_assert(strings_equal(“abc”, “abc” ), “strings are equal”); static_assert(!strings_equal(“abc”, “abcd”), “strings are not equal”); return 0; } Demo

‘Delegate ‘System.Action’ does not take 0 arguments.’ Is this a C# compiler bug (lambdas + two projects)?

FINAL UPDATE: The bug has been fixed in C# 5. Apologies again for the inconvenience, and thanks for the report. Original analysis: I can reproduce the problem with the command-line compiler. It certainly looks like a bug. It’s probably my fault; sorry about that. (I wrote all of the lambda-to-delegate conversion checking code.) I’m in … Read more

Can GCC not complain about undefined references?

Yes, it is possible to avoid reporting undefined references – using –unresolved-symbols linker option. g++ mm.cpp -Wl,–unresolved-symbols=ignore-in-object-files From man ld –unresolved-symbols=method Determine how to handle unresolved symbols. There are four possible values for method: ignore-all Do not report any unresolved symbols. report-all Report all unresolved symbols. This is the default. ignore-in-object-files Report unresolved symbols that … Read more

What does the “Multiple markers” mean?

“Multiple markers” just means “there’s more than one thing wrong with this line”. But the basic problem is that you’re trying to insert statements directly into a class, rather than having them in a constructor, method, initializer etc. I suggest you change your code to something like this: static Set<String> languages = getDefaultLanguages(); private static … Read more

Converting decimal to binary in Java

Integer.toBinaryString(int) should do the trick ! And by the way, correct your syntax, if you’re using Eclipse I’m sure he’s complaining about a lot of error. Working code : public class NumberConverter { public static void main(String[] args) { int i = Integer.parseInt(args[0]); toBinary(i); } public static void toBinary(int int1){ System.out.println(int1 + ” in binary … Read more