Skip to content

Object type comparison #9143

Answered by FaustVX
egorvts asked this question in Q&A
Feb 15, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Yes it's the how it's designed

  • obj is ReadOnlyBytes can be seen as if obj can be assigned to a variable of type ReadOnlyBytes
    • you can also use pattern matching: if (obj is ReadOnlyBytes bytes) { /* use bytes here */ }
  • obj?.GetType() == typeof(ReadonlyBytes) check if obj is exactly ReadonlyBytes
    • it's not the recommended way

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@TahirAhmadov
Comment options

Answer selected by egorvts
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants