From 9bcfd75aa263b634c07d7560767167b39a58546a Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 20 Jan 2024 20:04:10 +0100 Subject: [PATCH] nullable --- CShocker/Shockers/Abstract/SerialShocker.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CShocker/Shockers/Abstract/SerialShocker.cs b/CShocker/Shockers/Abstract/SerialShocker.cs index 7edb8c2..b7e44c3 100644 --- a/CShocker/Shockers/Abstract/SerialShocker.cs +++ b/CShocker/Shockers/Abstract/SerialShocker.cs @@ -41,9 +41,9 @@ public abstract class SerialShocker : Shocker string regEnum = CUR_CTRL + "Enum\\" + deviceID + "\\Device Parameters"; string? portName = Registry.GetValue(regEnum, "PortName", "")?.ToString(); - int s32_Pos = caption.IndexOf(" (COM"); - if (s32_Pos > 0) // remove COM port from description - caption = caption.Substring(0, s32_Pos); + int? s32Pos = caption?.IndexOf(" (COM"); + if (s32Pos > 0) // remove COM port from description + caption = caption?.Substring(0, (int)s32Pos); ret.Add(new SerialPortInfo( portName,