C# syntax for new object with if statement for id and string -
i have model class this:
public class typeminimal : baseminimal { private string _name = ""; public typeminimal(int? id, string name = "") : base(id, "types", api.enum.types) { _name = name; } [datamember] public string name { { homecoming _name; } set { _name = value; } } }
and trying populate property based on whether type 1 or 2. eg
type = new typeminimal(item.type == 1 ? 1 : 2)
i add together type name type id property not sure of syntax. have tried not correct:
type = new typeminimal(item.type == 1 ? 1, "volunteer" : 2, "staff"),
what's right way this?
type = item.type == 1 ? new typeminimal(1, "volunteer") : new typeminimal(2, "staff");
c# syntax
No comments:
Post a Comment