数组是对相同类型的一组数据的封装。数组定义的时候,要说明是对哪一种类型的封装,并且要指定长度。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace TestArrayList
{
class Program
{
static void Main(string[] args)
{
//System.Array
//1、数组[]特定类型、固定长度
string[] str1 = new string[];
str1[] = "a";
str1[] = "b";
str1[] = "c";
Console.WriteLine(str1[]); string[] str2 = new string[] { "a", "b", "c" };
Console.WriteLine(str2[]); string[] str3 = { "a", "b", "c" };
Console.WriteLine(str3[]); //2.二维数组
//int[,] intArray = new int
int[,] intArray = new int[, ];
intArray[, ] = ;
intArray[, ] = ;
intArray[, ] = ;
intArray[, ] = ;
intArray[, ] = ;
intArray[, ] = ;
Console.WriteLine("{0},{1},{2}", intArray[, ], intArray[, ], intArray[, ]);
Console.WriteLine("{0},{1},{2}", intArray[, ], intArray[, ], intArray[, ]); //3多维数组
int[, ,] intArray1 = new int[,,]
{
{{,},{,},{,}},
{{,},{,},{,}},
{{,},{,},{,}}
};
Console.WriteLine("多维数组");
Console.WriteLine("{0},{1},{2},{3},{4},{5}", intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ]);
Console.WriteLine("{0},{1},{2},{3}", intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ]);
Console.WriteLine("{0},{1},{2},{3},{4},{5}", intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ], intArray1[, , ]); //4交错数组即数组的数组
int[][] intArray2 = new int[][];
intArray2[] = new int[] { };
intArray2[] = new int[] { , };
intArray2[] = new int[] { , , };
intArray2[] = new int[] { , , , };
Console.WriteLine("交错数组");
for (int i = ; i < intArray2.Length; i++)
{
for (int j = ; j < intArray2[i].Length; j++)
{
Console.WriteLine("{0}", intArray2[i][j]);
}
}
Console.ReadKey();
int[] myIntArray = new int[] { , , , , };
Object[] myObjArray = new Object[] { , , , , };
Console.WriteLine("Initially,");
Console.Write("integer array:");
PrintValues(myIntArray);
Console.Write("Object array: ");
PrintValues(myObjArray); System.Array.Copy(myIntArray, myObjArray, ); Console.WriteLine("\n After copying the first two elements of the integer array to the Object array.");
Console.Write("integer array:");
PrintValues(myIntArray);
Console.Write("Object array: ");
PrintValues(myObjArray); System.Array.Copy(myObjArray, myObjArray.GetUpperBound() - , myIntArray, myIntArray.GetUpperBound() - , ); Console.WriteLine("\nAfter copying the last two elements of the object array to the integer array,");
Console.Write("integer array:");
PrintValues(myIntArray);
Console.Write("Object array:");
PrintValues(myObjArray);
Console.ReadKey();
} public static void PrintValues(Object[] myArr)
{
foreach (Object i in myArr)
{
Console.Write("\t{0}", i);
}
Console.WriteLine();
} public static void PrintValues(int[] myArr)
{
foreach (int i in myArr)
{
Console.Write("\t{0}", i);
}
Console.WriteLine();
}
}
}

运行结果如下:

数组是一种数据类型,并且二维数组在图像处理中会应用。一维数组的起始下标是[0]。二维数组的起始下标是[0,0]。交错也称参差数组的起始下标是[0][0]。

数组一定是固定长度和类型确定并且有序的,这种呆板的数据类型,导致它的INSERT,非常不方便,于是有了ArrayList

那么C#中数组是引用类型?还是值类型?C#中数组是引用类型,为什么是引用类型,依据是什么?

C# 数组Array的更多相关文章

  1. Java ArrayList和Vector、LinkedList与ArrayList、数组(Array)和列表集合(ArrayList)的区别

    ArrayList和Vector的区别ArrayList与Vector主要从二方面来说.  一.同步性:   Vector是线程安全的,也就是说是同步的,而ArrayList是线程序不安全的,不是同步 ...

  2. go 数组(array)、切片(slice)、map、结构体(struct)

    一 数组(array) go语言中的数组是固定长度的.使用前必须指定数组长度. go语言中数组是值类型.如果将数组赋值给另一个数组或者方法中参数使用都是复制一份,方法中使用可以使用指针传递地址. 声明 ...

  3. javascript类型系统——数组array

    × 目录 [1]创建 [2]本质 [3]稀疏[4]长度[5]遍历[6]类数组 前面的话 除了对象之外,数组Array类型可能是javascript中最常用的类型了.而且,javascript中的数组与 ...

  4. swift基本用法-数组array

    数组简单用法 //------------------------------------------------------------------------------ // 1. 数组定义 / ...

  5. C#中数组Array、ArrayList、泛型List<T>的比较

    在C#中数组Array,ArrayList,泛型List都能够存储一组对象,但是在开发中根本不知道用哪个性能最高,下面我们慢慢分析分析. 一.数组Array 数组是一个存储相同类型元素的固定大小的顺序 ...

  6. Javascript基础系列之(四)数据类型 (数组 array)

    字符串,数值,布尔值都属于离散值(scalar),如果某个变量是离散的,那么任何时候它只有一个值. 如果想使用变量存储一组值,就需要使用数组(array). 数组是由多个名称相同的树值构成的集合,集合 ...

  7. AS3 - 数组Array的几个常用方法(附样例)

    AS3 - 数组Array的几个常用方法(附样例) 2015-03-30 10:39发布:hangge浏览:241   Flex/Flash开发中,经常会使用到数组,下面总结了一些数组的常用方法. 1 ...

  8. Linux数组array基础

    Linux数组array基础[${a[*]}和$a的区别] Bash中,数组变量的赋值有两种方法: (1) name = (value1 ... valuen) 此时下标从0开始 (2) name[i ...

  9. 学习Swift -- 数组(Array) - 持续更新

    集合类型--数组 Array是Swift中的一种集合类型:数组,数组是使用有序列表储存同一类型的多个值,与OC的NSArray的最大不同是,Swift的数组是值类型,OC的数组是引用类型 声明数组的方 ...

  10. 数据结构之数组Array

    数组Array 基本操作 Status InitArray(int dimm,...)//若维数dim和随后的各维长度合法,则构造相应的数组A,并返回OK Status DestroyArray() ...

随机推荐

  1. 虚拟机console基础环境配置——安装VMware Tools

    1. 虚拟机设置中点击安装2. 虚拟机中挂载VMware Tools镜像3. 解压安装4. 配置共享目录5. 有关VMware Tools 1. 虚拟机设置中点击安装 VMware workstati ...

  2. 查看Linux下系统资源占用常用命令(top、free、uptime)

    本文介绍下,在linux中查看系统资源占用的三个命令:top.free.uptime,通过实例学习下它们的用法,有需要的朋友参考下 一,top命令 1.作用top命令用来显示执行中的程序进程,使用权限 ...

  3. centos7安装libgdiplus。netcore生成验证码,处理图片

    yum install autoconf automake libtool yum install freetype-devel fontconfig libXft-devel yum install ...

  4. OsharpNS轻量级.net core快速开发框架简明入门教程-从零开始启动Osharp

    OsharpNS轻量级.net core快速开发框架简明入门教程 教程目录 从零开始启动Osharp 1.1. 使用OsharpNS项目模板创建项目 1.2. 配置数据库连接串并启动项目 1.3. O ...

  5. Centos7 nginx 虚拟主机、反向代理服务器及负载均衡,多台主机分离php-fpm实验,之强化篇,部署zabbix为例

    一.简介 1.由于zabbix是php得,所有lnmp环境这里测试用的上一个实验环境,请查看https://www.cnblogs.com/zhangxingeng/p/10330735.html : ...

  6. SSM框架视频资料

    SSM框架视频资料 进行过 Java Web 项目开发的同学,可能都知道 SSM 框架,即 Spring + SpringMVC + Mybatis .很多项目的主体框架都是采用这种模式,这也是 Ja ...

  7. CSS 火焰?不在话下

    正文从下面开始. 今天的小技巧是使用纯 CSS 生成火焰,逼真一点的火焰. 嗯,长什么样子?在 CodePen 上输入关键字 CSS Fire,能找到这样的: 或者这样的: 我们希望,仅仅使用 CSS ...

  8. T-SQL语法基础

    一.T-SQL语言的分类 DDL-数据定义语言 create-创建 alter-修改 drop-删除(针对对象) DML-数据操作语言 Insert-插入 update-更新 delete-删除(针对 ...

  9. CASE 表达式

    通过本篇文章我们来学习一下CASE表达式的基本使用方法. CASE表达式有简单 CASE表达式(simple case expression)和搜索 CASE表达式(searched caseexpr ...

  10. linux open write lseek的API和应用

    1, open #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int open(c ...