Home Help Center

How to serialize named tuples (C#)?

MikeOneMikeOne Member Mike MillerOrganization: PersonalProject: Client/Server application for displaying Controlling data

Hi,

is there a best prectise how to work with named tuples in C#?

What would be the best way to serialize such a named tuple construct using ice/slice2cs:

List<(string Key, int Benchmark, List<(DateTime Date, int Count)>)>

Any help would me much appreciated.

Kind regards
Mike

Tagged:

Best Answer

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    Hi Mike,

    Ice cannot directly send your named tuples, you have to use types defined in Slice, here you can probably use a couple of structs and sequences like in:

    struct BenchmarkCount
    {
        long Data; // Send date as a long
        int Count;
    }
    
    sequence<BenchmarkCount> BenchmarkCountSeq; 
    
    struct BenchmarkInfo
    {
        string Key;
        int Benchmark;
        BenchmarkCountSeq Counters;
    }
    
    sequence<BenchmarkInfo> BenchmarkInfoSeq;
    

Answers

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    Hi Mike,

    Ice cannot directly send your named tuples, you have to use types defined in Slice, here you can probably use a couple of structs and sequences like in:

    struct BenchmarkCount
    {
        long Data; // Send date as a long
        int Count;
    }
    
    sequence<BenchmarkCount> BenchmarkCountSeq; 
    
    struct BenchmarkInfo
    {
        string Key;
        int Benchmark;
        BenchmarkCountSeq Counters;
    }
    
    sequence<BenchmarkInfo> BenchmarkInfoSeq;
    
Sign In or Register to comment.