首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

分段字符串,用逗号,但是最后一个就没逗号

2012-10-21 
分段字符串,用逗号,但是最后一个就没有逗号using Systemusing System.Collections.Genericusing System.

分段字符串,用逗号,但是最后一个就没有逗号

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace ADOperation{    public partial class Form2 : Form    {        public Form2()        {            InitializeComponent();            MessageBox.Show("welcome " + SpiltString() + " come here!");        }        public List<Student> StudentList()        {            List<Student> listStudent = new List<Student>();            Student s1 = new Student();            s1.ID = 1;            s1.Name = "apple";            listStudent.Add(s1);            Student s2 = new Student();            s2.ID = 2;            s2.Name = "wendy";            listStudent.Add(s2);            Student s3 = new Student();            s3.ID = 3;            s3.Name = "XiaoMin";            listStudent.Add(s3);            Student s4 = new Student();            s4.ID = 4;            s4.Name = "Easy";            listStudent.Add(s4);            return listStudent;        }        private string SpiltString()        {            string students = string.Empty;            string student = string.Empty;            foreach (Student s in StudentList())                student += s.Name + ",";            int jobNoIndex = (student + "last").IndexOf(",last");            students = (student + "last").Substring(0, jobNoIndex);            return students;        }    }    public class Student    {        public decimal ID { get; set; }        public string Name { get; set; }    }}

热点排行