我有類在那裏我有FreeDressingItems,FreeToppingItems收集,FreeInstructionItems我怎樣才能填寫另一個班的班級屬性?
就是這個樣子的每一個填補selectedCustomization我還有一個屬性在這個類public string Items { get { return GetAllItems(); } }
,我想,以填補,使其保持相同類別類型的所有catetoryname,以便我可以將其綁定到網格,並以逗號分隔的形式顯示其所有值。
我有以下代碼可以有人幫助我我怎麼能這樣做。
public class selectedCustomization
{
public CategoryType TypeName { get; set; }
public string CategoryName { get; set; }
public string ItemName { get; set; }
public int SourceID { get; set; }
public string Items { get { return GetAllItems(); } }
private string GetAllItems()
{
switch (TypeName)
{
case CategoryType.Dressing:
{
cFreeCustomization cfreeCust = new cFreeCustomization();
break;
}
case CategoryType.Topping:
break;
case CategoryType.SpecialInstruction:
break;
}
}
}
這是另一個類cFreeCustomization
public List<selectedCustomization> SelectedItems
{
get
{
libDBDataContext cn = new libDBDataContext();
List<selectedCustomization> lst = new List<selectedCustomization>();
lst.AddRange(
(from xx in this.FreeDressingItems
select new selectedCustomization() { TypeName = CategoryType.Dressing, CategoryName = xx.DressingInfo.CatName, ItemName = xx.DressingInfo.Description }
).ToList()
);
lst.AddRange(
(from xx in this.FreeToppingItems
select new selectedCustomization() { TypeName = CategoryType.Topping, CategoryName = xx.ToppingInfo.CatName, ItemName = xx.ToppingInfo.Description }
).ToList()
);
lst.AddRange(
(from xx in this.FreeInstructionItems
select new selectedCustomization() { TypeName = CategoryType.SpecialInstruction, CategoryName = xx.InstructionInfo.CatName, ItemName = xx.InstructionInfo.Description }
).ToList()
);
return lst;
}
}
我怎樣才能使以逗號分隔的形式selectedCustomization的TIEMS?
如果您的財產正在幕後調用方法,則只需刪除該財產併爲相同的目的創建一個方法。 – Icarus
那麼我該如何訪問該集合? – NoviceToDotNet
你能給我一些想法,我長時間工作嗎? – NoviceToDotNet