我要尝试尽可能简化这个词,因为我的问题相当复杂(或者我认为!!!)。在C中的变量内部的字符串分裂#
目前我有一个与中继器相关的变量,它列出了业务中各个员工的一组配置文件。
在变量中,我有一个字段“Job_Title”,它包含他们工作的扇区和工作标题以'/'分隔。我试图实现的是根据“Job_Title”字符串中的扇区分配一组DIV类。
现在我可以通过以下操作
DT_Control_Profile Pro =
db.DT_Control_Profiles
.SingleOrDefault(x => x.PageControlID == PageControl_ID);
if (Pro != null)
{
String[] cutsector = Pro.Job_Title.Split('/');
foreach (string s in cutsector)
{
if (s.Trim().ToUpper() == "WELL ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon conwelleng");
}
else if (s.Trim().ToUpper() == "RESEVOIR ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon conreseng");
}
else if (s.Trim().ToUpper() == "GEO SCIENCES")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon congeoscie");
}
else if (s.Trim().ToUpper() == "FACILITES ENGINEERING")
{
DIV_SECOTR.Attributes.Add("class", "sectorcon confacilieng");
}
};
但是我很努力变戏法实现这一使用变量,从而牵引多个配置文件到页面上的方式对一个配置文件实现这一目标!
到目前为止,我有这样的:
var leaders = from x in db.DT_Control_Profiles
where x.FeatureProfile == true
&& x.DT_PageControl.DT_SitePage.VennID == codesnippets.VennID
select new
{
img = Path + x.ImageUrl,
x.Job_Title,
x.Name,
about = codesnippets.StringSize(x.Biography, 100),
link = "~/" + x.DT_PageControl.DT_SitePage.PageName,
};
我认为,解决办法在于foreach循环,但我不知道从哪里开始!
任何人都可以指出我在正确的方向?