.NET Programming Weekly Issue 2 - January 12, 2020
- Yes, a new array is allocated every time.
- There is of course one special case where “interning” of the kind we discuss here, could be easy to do, and that is for length-zero arrays.
- Unity Scripting Tip.
- Do not new them every time you need to yield them, but cache the variable and reuse it.
C# 7.2, the compiler will make defensive copies of struct values in cases where the underlying location is considered readonly, because the compiler must assume the worst case which some operation may mutate the content of the struct and hence violates the readonly contract on the field.
C# 7.2, C# added the ability to mark a struct declaration as readonly. It allows the compiler to avoid defensive copies of struct values.
- An issue conversation from
- Although the title was
Nullable <T> must be a readonly struct, it
did not do so in the end. Because it’s not so much making Nullable readonly that’s the problem, but rather changing its value field to be readonly (and then the type can’t be readonly).
- This article explains the older
RSA encryption method. But still helpful.
- Explained why https is needed.
Symmetric encryption: use the same encryption key on both ends, such as the home wifi.
Asymmetric encryption: you’re using two different keys, one to encrypt and one to decrypt.
- What https does not do.
- This article introduces some best practices to avoid heap memory allocation in Unity to avoid the GC of managed code. Of course, these suggestions are useful in other field of C # code programming too.
- Introduce some useful tools. Such as the Project Auditor maintained by Unity and the Performance Testing Extension for Unity Test Runner.