C#语法(List、方法的调用)

本文介绍了C#中字符串转数组、数组转字符串的方法,并展示了类的静态与非静态调用,以及各种操作符的使用,包括赋值、逻辑运算、算术运算、位操作和条件判断等。
摘要由CSDN通过智能技术生成
class GroupSample1
{
    // The element type of the data source.
    public class Student
    {
        public string First { get; set; }
        public string Last { get; set; }
        public int ID { get; set; }
        public List<int> Scores;
    }


    public static List<Student> GetStudents()
    {
         // Use a collection initializer to create the data source. Note that each element
          //  in the list contains an inner sequence of scores.
          List<Student> students = new List<Student>
           {
           new Student {First="Svetlana", Last="Omelchenko", ID=111, Scores= new List<int> {97, 72, 81, 60}},
           new Student {First="Claire", Last="O'Donnell", ID=112, Scores= new List<int> {75, 84, 91, 39}},
           new Student {First="Sven", Last="Mortensen", ID=113, Scores= new List<int> {99, 89, 91, 95}},
           new Student {First="Cesar", Last="Garcia", ID=114, Scores= new List<int> {72, 81, 65, 84}},
           new Student {First="Debra", Last="Garcia", ID=115, Scores= new List<int> {97, 89, 85, 82}} 
           };


        return students;


    }

}



//C#字符串转数组(循环输出)

            string str = "文学笔记|计算机笔记|物流笔记";
            string[] sarr = str.Split('|');
            foreach (var item in sarr)
            {
                Response.Write(item + "<br />");
            }



//C#字符串数组转字符串

           string str = "名字1|代码2|表格3";
            string[] sarr = str.Split('|');

          string arrStr = string.Join(",", sarr);//数组转成字符串
          Response.Write(arrStr);



//类的调用(加static与不加static)

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值