C# Conversion Help & PHP -
i have problem converting array php c#.
public $array = array(103 => array('', ''), 102 => array('', ''), 101 => array('', '', ''), 100 => array('', '', '', '')); this have:
public dictionary<int, list<string>> waddlesbyid = new dictionary<int, list<string>>(); problem whenever this:
sizeof($this->array[$waddleid]) - 1 that equals -1, when in c#:
waddlesbyid[waddleid].count - 1 equals 0. construct function:
string maxseats = string.empty; foreach (int waddleid in sledracing) { switch (waddleid) { case 103: case 102: maxseats = ","; break; case 101: maxseats = ",,"; break; case 100: maxseats = ",,,"; break; } if (waddlesbyid.containskey(waddleid)) { waddlesbyid[waddleid].add(maxseats); } else { list<string> newinner = new list<string>(); newinner.add(maxseats); waddlesbyid.add(waddleid, newinner); } } any appreciated
using .count automatically create entry. use waddlesbyid.containskey(waddleid) instead: http://msdn.microsoft.com/en-us/library/htszx2dy.aspx
Comments
Post a Comment