猿问

关于拼接字符串无效的问题

StringBuilder s = new StringBuilder();

this.ddlGoodsClassName.SelectedValue = "3";

s=s .Append("0");
s=s.Append(this.ddlGoodsClassName.SelectedValue.ToString().Trim()); 
s=s.Append("000001");
goods.GoodsId =Convert.ToString(s);

执行后显示的依然是3,而我要的效果是03000001,如何解决?


慕婉清6462132
浏览 530回答 2
2回答

临摹微笑

StringBuilder s = new StringBuilder();//对的this.ddlGoodsClassName.SelectedValue = "3";s=s .Append("0");//错的,而直接:s .Append("0")s=s.Append(this.ddlGoodsClassName.SelectedValue.ToString().Trim()); //和上面一样!不用等于!s=s.Append("000001");//同上goods.GoodsId =Convert.ToString(s);//goods.GoodsId = s.ToString()
随时随地看视频慕课网APP
我要回答