I made a code with php and now I'm trying to convert this in C#, but it isn't working
This is the php code:
function is_deelverzameling_van($eerste_verzameling,$tweede_verzameling)
{
foreach($eerste_verzameling as $value)
{
if(array_search($value,$tweede_verzameling)==FALSE)
{
return FALSE;
}
}
return TRUE;
}
This is the C# code:
public bool isDeelverzamelingVan(List<int> eersteVerzameling, List<int> tweedeVerzameling)
{
foreach (int element in eersteVerzameling)
{
if (!tweedeVerzameling.Contains(element))
{
return false;
}
}
return true;
}
ERROR:
An unhandled exception of type 'System.NullReferenceException' occurred in connectiondb.exe
Additional information: De objectverwijzing is niet op een exemplaar van een object ingesteld.
In C# there's something wrong with the: if statement, but I can't find the problem. Can someone help me?
Aucun commentaire:
Enregistrer un commentaire