Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
Convert RepeatedField to List

.Net

My protobuf file:

message Result{
    repeated ListOfStrings lists = 1;
}

message ListOfStrings {
    repeated string strings = 1;
}

And I have a class with this property:

public List<List<string>> ListOfLists { get; set; }

Protobuf compiler generates RepeatedField collection and when I'm trying to pass this collection to ListOfLists.AddRange() I get this error:

cannot convert from 'Google.ProtobufCollections.RepeatedField<gRPC.ListOfStrings>' to 'System.Collection.Generic.IEnumerable<System.Collections.Generic.List<string>>

How to deal with it?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

A List<List<string>> is not the same as a list of things that have strings. You will probably need:

foreach (var list in outerList) {
    var inner = new ListOfStrings();
    inner.Strings.AddRange(list);
    obj.Lists.Add(inner);
}
over 4 years ago · Santiago Trujillo Relatório

0

Can you try the CopyTo method, doc

Sample Pseudocode code:

 Result result = ...
 foreach(var list in result.list)
 {
    string[] arr = new string[list.Count];
    list.CopyTo(arr,0);
    ListOfLists.Add(arr.ToList());
 }
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda