我如何在另一个班级中填写一个班级的财产?

编程入门 行业动态 更新时间:2024-10-24 16:29:39
本文介绍了我如何在另一个班级中填写一个班级的财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个类,其中有FreeDressingItems,FreeToppingItems,FreeInstructionItems的集合

I have class where i have the collection of FreeDressingItems, FreeToppingItems, FreeInstructionItems

都填充selectedCustomization我在此类public string Items { get { return GetAllItems(); } }

that is like this each of which fill selectedCustomization i have another property in this class public string Items { get { return GetAllItems(); } }

我要填写,以便保留相同类别类型的所有分类名称,以便我可以轻松地将其绑定到网格并以逗号分隔的形式显示其所有值.

that i want to fill so that it keeps the all catetoryname for the same category type so that i can bind it to grid easily and display all its value in comma separated form.

我有以下代码可以帮助我如何实现这一目标.

i have following code could somebody help me how can i acineve this.

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

this is another class 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的关系?

How can i make tiems of selectedCustomization in comma separated form?

推荐答案

我相信 GetAllItems 方法应如下所示:

I believe the method GetAllItems should be like below:

private string GetAllItems() { cFreeCustomization cfreeCust = new cFreeCustomization(); var ls = cfreeCust.SelectedItems.FindAll(I => I.TypeName == this.TypeName); return string.Join(",", ls.Select(I => I.CategoryName).ToArray()); }

这将解决您的问题.

更多推荐

我如何在另一个班级中填写一个班级的财产?

本文发布于:2023-10-31 05:56:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545209.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:班级   财产   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!