Добрый день!
У меня есть две коллекции IEnumerable<Repo>
и List<string>
.
Есть два метода, которые возвращают эти коллекции.
public IEnumerable<Repo> CollectionWithUrl()
{
StreamReader jsonfile = new StreamReader("file.json");
string json = jsonfile.ReadToEnd();
IEnumerable<Repo> repos = JsonConvert.DeserializeObject<IEnumerable<Repo>>(json);
return repos;
}
public List<string> CollectionWithHash()
{
Repo CollWU = new Repo();
var CollWithURL = CollWU.CollectionWithUrl();
List<string> listHashRepo = new List<string>();
foreach (var item in CollWithURL)
{
listHashRepo.Add(item.GetHash(item.url.ToString()));
}
return listHashRepo;
}
А я пытаюсь их вывести в консоль таким способом:
Repo printhash = new Repo();
var printhashvar = printhash.CollectionWithHash();
Repo printurl = new Repo();
var printurlvar = printurl.CollectionWithUrl();
Console.WriteLine("CollectionWithHASH");
Console.WriteLine(printhashvar);
Console.WriteLine();
Console.WriteLine("CollectionWithURL");
Console.WriteLine(printurlvar);
Console.WriteLine();
И они не выводяться в консоле. Хотя в первой коллекции должны быть хэш-коды, а во второй ссылки!
А пишется в консоле:
CollectionWithHASH
System.Collections.Generic.List'1[ConsoleAppOOP.Repo]
CollectionWithURL
System.Collections.Generic.List'1[System.String]
Помогите решить проблему. Спасибо!
foreach
напримерRepo
, просто не понятно, что там у Вас