从定界字符串填充列表属性

编程入门 行业动态 更新时间:2024-10-28 14:22:58
本文介绍了从定界字符串填充列表属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是一个简单的应用程序,但是我对ASP.NET MVC有点陌生,所以我在解决如何实现此目标方面遇到了一些麻烦,因为

This is kind of a simple application but I'm a bit new to ASP.NET MVC so I'm having a bit of trouble wrapping my head around how to accomplish this because the

我有两个班级:

public class BugAssignment { public int BugAssignmentID { get; set; } public int BugNumber { get; set; } public int UserID { get; set; } public virtual User User { get; set; } } public class BugAssignmentList { public int BugAssignmentListID { get; set; } public string Name { get; set; } public List<BugAssignment> BugAssignments { get; set; } }

我想要做的是填充BugAssignments列表,给定用户输入的BugNumbers分隔字符串(即208,576,403).我猜想它会爆炸字符串,遍历并创建BugAssignment对象,存储到列表中并设置BugAssignments属性.我该怎么办?

What I want do is populate the List of BugAssignments given user inputted delimited string of BugNumbers from (i.e. 208,576,403). I'm guessing it would explode the string, loop through and create the BugAssignment objects, store into a list and set the BugAssignments property. How could I accomplish this?

此外,我将SQL Server 2008作为数据库引擎使用Entity Framework Code-first.

Also, I am using Entity Framework Code-first with SQL server 2008 as my database engine.

推荐答案

如果您坚持将字符串转换为字符串数组...

If you're stuck on converting the string to an array of strings...

使用 String.Split().

string[] StringArray = String.Split(BugAssignments , ",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

从那里开始,直接遍历数组并完成其余工作应该很简单.如果您遇到其他问题,请告诉我们.

From there, it should be straightforward to loop through the array and do the remainder of the work. If you're stuck on a different part, let us know.

更多推荐

从定界字符串填充列表属性

本文发布于:2023-07-22 22:08:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1191459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   属性   列表   定界

发布评论

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

>www.elefans.com

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