Or versus OrElse

OrElse is a short-circuiting operator, Or is not. By the definition of the boolean ‘or’ operator, if the first term is True then the whole is definitely true – so we don’t need to evaluate the second term. OrElse knows this, so doesn’t try and evaluate temp = 0 once it’s established that temp Is … Read more

Difference between DirectCast() and CType() in VB.NET

The first thing to note is VB.NET does not have a direct analog to C#’s (type)instance casting mechanism. I bring this up because it’s useful as a starting point and common reference in comparing the two VB.NET operators (and they are operators, not functions, even though they have function semantics). DirectCast() is more strict than … Read more

.NET Core doesn’t know about Windows 1252, how to fix?

To do this, you need to register the CodePagesEncodingProvider instance from the System.Text.Encoding.CodePages package. To do that, install the System.Text.Encoding.CodePages package: dotnet add package System.Text.Encoding.CodePages Then (after implicitly or explicitly running dotnet restore) you can call: Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var enc1252 = Encoding.GetEncoding(1252); Alternatively, if you only need that one code page, you can get it directly, … Read more

Write text files without Byte Order Mark (BOM)?

In order to omit the byte order mark (BOM), your stream must use an instance of UTF8Encoding other than System.Text.Encoding.UTF8 (which is configured to generate a BOM). There are two easy ways to do this: 1. Explicitly specifying a suitable encoding: Call the UTF8Encoding constructor with False for the encoderShouldEmitUTF8Identifier parameter. Pass the UTF8Encoding instance … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)