c#数据类型

结构体类型是一种值类型,类类型是一种引用类型

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

struct student
{
    public int no;
    public string name;
    public string phone;
    public student(int stu_no, string stu_name, string stu_phone)
    {
        no = stu_no;
        name = stu_name;
        phone = stu_phone;
    }
}

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            student stu = new student(61101, "zhangsan", "111111");
            Console.WriteLine(stu.no);
            Console.WriteLine(stu.phone);
            Console.WriteLine(stu.name);
            Console.ReadLine();
        }
    }
}


数组类型

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
class test
{
    string []    m1;  // 一维字符串数组
    string [,]   m2   //二维字符串数组
    string [, ,] m3   //三维字符串数组
    short [][]   n1  //锯齿形数组n1
    int [][][]   n2  //三层数组n2;
}
*/

namespace aaa //lx424
{
    class arraytest
    {
        static void ain()
        {
            int[] arr = new int[5];
            for (int i = 0; i < arr.Length; i++)
                arr[i] = Convert.ToInt32( Console.ReadLine() );
            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine("{0}", arr[i]);
        }
    }
}

数组做参数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class test2
{
    static void t(char[] arr) { }
    public static void Main()
    {
        t(new char[] { 'a', 'b', 'c' }); //必须经过初始化
        Console.WriteLine("输出");
        Console.ReadLine();
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值