| Start |
|---|
| Using unsafe with arrays When accessing arrays with pointers, there are no bounds check and therefore no Assigning values to an array with a pointer: While the safe and normal counterpart would be: The unsafe part will generally be faster and the difference in performance can vary depending on the complexity of the elements in the array as well as the logic applied to each one. Even though it may be faster, it should be used with care since it is harder to maintain and easier to break. |
Using unsafe with strings |
Unsafe Array Index Running this code creates an array of length 3, but then tries to get the 5th item (index 4). On my machine, this printed Without the Remarks
For instance, when you use a for loop an array like so: .NET Framework ensures that you do not exceed the bounds of the array, throwing an However, if you use unsafe code, you may exceed the array's bounds like so: |
Read Article
https://develop.horje.com/learn/1434/reference