c#实现二维数组转置及二维数组列表List<>转置
面利用c#利器也实现一遍二维数组的转置 首先来看二维数组转置代码: Code [http://www.xueit.com] class Program{ public static string [,] Rotate( string [,] array) { int x = array.GetUpperBound( 0 ); // 一维 int y
面利用c#利器也实现一遍二维数组的转置
首先来看二维数组转置代码:

class Program { public static string[,] Rotate(string[,] array) { int x = array.GetUpperBound(0); //一维 int y = array.GetUpperBound(1); //二维 string[,] newArray = new string[y 1, x 1]; //构造转置二维数组 for (int i = 0; i <= x; i ) { for (int j = 0; j <= y; j ) { newArray[j, i] = array[i, j]; } } return newArray; } static void Main(string[] args) { string[,] array = new string[4, 2]; for (int i = 0; i < 4; i ) { for (int j = 0; j < 2; j ) { array[i, j] = i.ToString() j.ToString(); } } //显示原数组 Console.WriteLine("Source Array:"); for (int i = 0; i < 4; i ) { string soureResult = string.Empty; for (int j = 0; j < 2; j ) { soureResult = array[i, j] " "; } Console.WriteLine(soureResult); } string[,] newArray = Rotate(array); //显示转置后的数组 Console.WriteLine("Destiney Array:"); for (int i = 0; i < 2; i ) { string dstResult = string.Empty; for (int j = 0; j < 4; j ) { dstResult = newArray[i, j] " "; } Console.WriteLine(dstResult); } Console.ReadLine(); } }
好了,下面接着看二维数组列表List<>的转置
收藏文章
精彩图集
精彩文章
- 暂无记录。
热门标签
cat
msxml3.dll
动态活动窗口
自定义函数
查询封装
sizeof用法
数组乱序方
表数据
终止多线程
mac地址
参数列表
office
CURD操作
非聚集
goto
attr
奶牛生子
RelativeLayo
RTTI机制
pymssql
IIS的备份
变色验证码
Python类
删除字符串
mysql免安
位字段
交叉表
本地路径
@@IDENTITY
页面链接
vsftpd
调用C#类
低权限
1000以内的素数
避免闪烁
手机配置信息
php安装xdebug
转列
JVM性能优化
校验email
ljust
curl_init
延迟
四方定理
取出数据
快照
timestamps
ui线程
sendRedirect
Top功能
randomaccess
切割多层字符
修
不一致
验证码生成
锁定网页
ACE_Task
strcat函数实现
监控账户
Remind
赞助商链接
@CopyRight 2002-2008, 1SOHU.COM, Inc. All Rights Reserved QQ:1010969229