[置顶] c#拼接字符串

最近项目中用到了动态调用数据,需要拼接字符串。


        //酒店信息div
        public string ShowCityHotel(IQueryable<HotelLuckyRoomModel> list, string id, string isshow)
        {
            StringBuilder sb = new StringBuilder();
            int k = 0 + (Convert.ToInt32(id) * 10);
            foreach (HotelLuckyRoomModel li in list)
            {
                k++;
                string xj = GetStarString(li.rate);
                sb.Append(string.Format("<div class='list_items' id='wantGoOutChn{0}' onmouseover=\"wantGoListOver('{1}','Chn')\" >", k, k));
                sb.Append("<dl>");
                sb.Append(string.Format(" <dt><dfn>¥</dfn>{0}元起 </dt>", li.Price));
                sb.Append(string.Format(" <dd class='hotel_name'><a href='http://cn.chinahotel.com/{0}.html' > {1}</a> </dd>", li.UrlName, li.HotelNameCN));
                sb.Append(string.Format(" <dd class='hotel_map'><a href='http://cn.chinahotel.com/Maps/{0}.html' >【地图】 </a> </dd>", li.ID));
                sb.Append("<dd class=‘star_level’></dd>");
                //sb.Append(string.Format("  <dd>{0}</dd>" ,xj));

                sb.Append(string.Format("<dd style=‘float:right’ class=‘address_position’>位于:{0}</dd>", li.CommercialName));

                sb.Append("</dl></div>");
                sb.Append(string.Format("<div class='list_items_hover' id='wantGoOverChn{0}' style='display: none'>", k));

                sb.Append("<dl>");
                sb.Append(string.Format(" <dt><dfn>¥</dfn>{0}元起 </dt>", li.Price));
                sb.Append(string.Format(" <dd class='hotel_name'><a href='http://cn.chinahotel.com/{0}.html' > {1}</a> </dd>", li.UrlName, li.HotelNameCN));
                sb.Append(string.Format(" <dd class='hotel_map'><a href='http://cn.chinahotel.com/Maps/{0}.html' >【地图】 </a> </dd>", li.ID));
                sb.Append(" <dd class='star_level'></dd>");
                //sb.Append(string.Format("  <dd>{0}</dd>", xj));
                sb.Append(string.Format("<dd style=‘float:right’ class=‘address_position’>位于:{0}</dd>", li.CommercialName));
                sb.Append("</dl>");

                sb.Append("  <ul class='index_center_hotel'>");
                sb.Append(string.Format("<li class='index_center_pic'> <a href='http://cn.chinahotel.com/{0}.html' title='{1}' target='_blank'> ", li.UrlName, li.HotelNameCN));
                sb.Append(string.Format("<img src='{0}'  alt='{1}'/></a> </li>", li.ImageFile, li.HotelNameCN));
                sb.Append("<li class='index_center_hoteladress'>");
                sb.Append(string.Format(" <p>地址:{0}</p>", li.HotelAddress));
                sb.Append(string.Format(" <p> 简介:{0}</p>", li.Description));
                sb.Append(" </li> </ul> </div>");
            }
            return sb.ToString();
        }

 

你可能感兴趣的:(String,list,C#,Class,div,float)