tobiasholmdk
tobiasholmdk

Reputation: 119

How to go from RepeatedField to a list or array?

I have a RepeatedField, which i need to Convert to a .NET List or Array.

How can this be done? Is there a better way than taking each element and putting into a new list using a forEach? This seems to be quite a performance hit when dealing with huge data sets.

Example, I want this to become a

List<string>
message keysList {
    repeated string keys = 1;
}

Upvotes: 1

Views: 1485

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1063864

Would using protobuf-net be an option? Since it is code-first, you can do what you want:

[ProtoContract]
class Whatever {
    [ProtoMember(1)]
    public List<string> TheData {get;set;}
}

Upvotes: 1

Related Questions