summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1InputStream.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/Asn1InputStream.cs')
-rw-r--r--crypto/src/asn1/Asn1InputStream.cs15
1 files changed, 6 insertions, 9 deletions
diff --git a/crypto/src/asn1/Asn1InputStream.cs b/crypto/src/asn1/Asn1InputStream.cs
index 33e7b0e0c..1df6a0206 100644
--- a/crypto/src/asn1/Asn1InputStream.cs
+++ b/crypto/src/asn1/Asn1InputStream.cs
@@ -21,17 +21,14 @@ namespace Org.BouncyCastle.Asn1
 
         internal static int FindLimit(Stream input)
         {
-            if (input is LimitedInputStream)
-                return ((LimitedInputStream)input).Limit;
+            if (input is LimitedInputStream limited)
+                return limited.Limit;
 
-            if (input is Asn1InputStream)
-                return ((Asn1InputStream)input).Limit;
+            if (input is Asn1InputStream asn1)
+                return asn1.Limit;
 
-            if (input is MemoryStream)
-            {
-                MemoryStream mem = (MemoryStream)input;
-                return (int)(mem.Length - mem.Position);
-            }
+            if (input is MemoryStream memory)
+                return (int)(memory.Length - memory.Position);
 
             return int.MaxValue;
         }