From cfd412529e27d273257c262f555dd4d9a7ed5996 Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Mon, 30 Jul 2018 21:34:59 +0200 Subject: [PATCH] Use switch instead of if/elseif. --- src/Renci.SshNet/Session.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index 3d4d09f1..85eeb6b8 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -2287,19 +2287,18 @@ namespace Renci.SshNet byte[] address; - if (ip.AddressFamily == AddressFamily.InterNetwork) + switch (ip.AddressFamily) { - addressType = 0x01; // IPv4 - address = ip.GetAddressBytes(); - } - else if (ip.AddressFamily == AddressFamily.InterNetworkV6) - { - addressType = 0x04; // IPv6 - address = ip.GetAddressBytes(); - } - else - { - throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip)); + case AddressFamily.InterNetwork: + addressType = 0x01; // IPv4 + address = ip.GetAddressBytes(); + break; + case AddressFamily.InterNetworkV6: + addressType = 0x04; // IPv6 + address = ip.GetAddressBytes(); + break; + default: + throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip)); } return address;