Use Position
when setting an absolute position and Seek
when setting a relative position. Both are provided for convenience so you can choose one that fits the style and readability of your code. Accessing Position
requires the stream be seekable so they're safely interchangeable.
You can look at the source code for both methods to find out:
The cost is almost identical (3 if
s and some arithmetics). However, this is only true for jumping to absolute offsets like Position = 0
and not relative offsets like Position += 0
, in which case Seek
seems slightly better.
However, you should keep in mind that we are talking about performance of a handful of integer arithmetics and if
checks, that's like not even accurately measureable with benchmarking methods. Like others already pointed out, there is no significant/detectable difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With