Verbatim String Literal in C#

Hi Folks,

In this short post I talk about how to write verbatim string literals in C#. You write this by using using the @ keyword just before the string. What does a verbatim string literal mean? It means that the characters in it will be interpreted verbatim. This means that escape sequences such as \ \ for backslash, hexadecimal escape sequences such as \x0041 for uppercase A, and Unicode sequences such as \u0041 for uppercase A, are interpreted literally. To demonstrate this, consider that the following two strings are equivalent.

string filename1 = @"c:\documents\file.txt";
string filename2 = "c:\\documents\\file.text";

That’s all for now. Till next time, happy software development.

 

Reference

1. Verbatim text and strings – @ – C# reference. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim

How to resolve error of java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.ProcessEnivironment java.lang.ProcessEnvironment.theEnvironment accessible: module java.lang.base does not “opens java.lang” to unnamed module

Hi Folks,

In this short post we talk about how to work around an error I got when trying to build a Kotlin project. The error looks like:

java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.ProcessEnivironment java.lang.ProcessEnvironment.theEnvironment  accessible: module java.lang.base does not “opens java.lang” to unnamed module

After some research, I found a way to build the project. The workaround is as follows:

  • Click to Edit Configurations…
  • Find the current build configuration
  • Paste the following under VM options.
--add-opens java.base/java.lang=ALL-UNAMED --add-opens java.base/java.nio=ALL-UNAMED --add-opens java.base/sun.nio.ch=ALL-UNAMED
  • Click Apply
  • Close the configurations dialog.

That’s it. Your build should now work. That’s all for now. Till next time, happy software development.