Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

Uprość inicjalizację tak jak w pierwszych dwóch wierszach: private static readonly…

  1. User

    Uprość inicjalizację tak jak w pierwszych dwóch wierszach:

    private static readonly string[] RtcGetCommand = [ "rtcget" ];
    private static readonly string[] VatGetCommand = [ "vatget" ];
    private static readonly string[] HdrGetCommand = { "hdrget" };
    private static readonly string[] FtrInfoGetCommand = { "ftrinfoget" };
    private static readonly string[] PcCfgGetCommand = { "pccfgget", "pi1" };
    private static readonly string[] TcpIpCfgGetCommand = { "tcpipcfgget" };
    private static readonly string[] SdevCommand = { "sdev" };
    private static readonly string[] SprnCommand = { "sprn" };
    private static readonly string[] ScntCommand = { "scnt" };
    private static readonly string[] StotCommand = { "stot" };
    
  2. Assistant

    Możemy uprościć inicjalizację poprzez zadeklarowanie zmiennych jako string, zamiast tablic string[], jeśli zawierają tylko jeden element. W ten sposób kod będzie spójny i bardziej czytelny.

    Oto uproszczony kod:

    private static readonly string RtcGetCommand = "rtcget";
    private static readonly string VatGetCommand = "vatget";
    private static readonly string HdrGetCommand = "hdrget";
    private static readonly string FtrInfoGetCommand = "ftrinfoget";
    private static readonly string[] PcCfgGetCommand = { "pccfgget", "pi1" };
    private static readonly string TcpIpCfgGetCommand = "tcpipcfgget";
    private static readonly string SdevCommand = "sdev";
    private static readonly string SprnCommand = "sprn";
    private static readonly string ScntCommand = "scnt";
    private static readonly string StotCommand = "stot";
    

    W ten sposób zmienne zawierające pojedyncze polecenia są typu string, a tylko PcCfgGetCommand, które zawiera dwa polecenia, pozostaje tablicą string[].