Click here to Skip to main content
15,936,430 members

Comments by Eddy Sels 2021 (Top 5 by date)

Eddy Sels 2021 8-May-24 15:00pm View    
Thank you for the suggestion, but I have a working app in python. I'm porting it to C# and .NET Core.
In python I use this code:
while index_species < len(birds["Species"]):
while index_birds < len(birds["Species"][specie[index_species]]):
if["Species"][specie[index_species]][index_birds]["Komt_voor_in"]) != None:
So the deserialization of Json in python is more useful than the one in C#.
I also had to change my Json to be useful in C# (had to remove the species root)
Eddy Sels 2021 7-May-24 5:58am View    
not really, but I have not used dictionaries before (I'm not a professional programmer). I tried to make classes of my own, but they didn't work so I left it up to visual studio to create the classes from my json file. I wanted to experiment with json but was not aware json is not the best option to use as a database.
Eddy Sels 2021 3-Sep-23 17:16pm View    
Well, this looks promising but I never created/used an Interface before so what I did is create IExportData.cs under models with this content:
namespace Boeken.Models
public class IExportData
string titel { get; }
string auteur { get; }
string hugo { get; }
string nebula { get; }
string locus { get; }
string categorie { get; }
string taal { get; }
string soort { get; }
public class ExportData:IExportData
string? titel { get; }
string? auteur { get; }
string? hugo { get; }
string? nebula { get; }
string? locus { get; }
string? categorie { get; }
string? taal { get; }
string? soort { get; }

I changed the NTK branch as speciefied but now I get following unexpected error:
CS0112:ExportData.titel is inaccessible due to its protection level
Did I put the IExportData.cs in the wrong place? I don't understand where this comes from.
Eddy Sels 2021 3-Sep-23 10:59am View    
Sorry that my hint in the titel was not clear enough. I tried your solution before but it does not work. The declaration of the var outside the if or switch statement gives an error when assigning the var. I tried to paste the error message as a screenshot but that is apparantly not possible so here is the error :
CS0029:Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type:string="" titel,string="" auteur,string="" hugo,string="" nebula,string="" locus="">>' to 'System.Collections.Generic.List<object>
When changing the declaration of Data into an object, then the assignement is ok but then the Data.Count gives an error and also further assignements of Data in the other switch branches.
I first thought it was the naming of the variable because I have a "using Boeken.Data" but Changing the name did not change anything either.
I don't see how I can declare a var that matches the compile time created Anonymous List
Eddy Sels 2021 3-Sep-23 6:18am View    
Thank you for your reply, but what I really want is to generalize the function and replace the if with a switch statement. The "NTK" is used for a table Book, but there are other tables I want to use this function for too. That's why I want the var defined outside the if statement. But as I understand from your answer, this is not possible?