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<>的转置
收藏文章
精彩图集
精彩文章
- 暂无记录。
热门标签
开头
重装失败
二分查找
WScript.Shel
自定义session
内置
最小公
jquery解析XM
援引
32
合并列表
过期时间
相互转换
encodeURICom
windows7
jni调用c
display
实现方法
静态数据成员
yii框架
链式二叉树
空间几何模型
监视按键
webapp滑动
删除字符串
默认浏览器
联合索引
异步编程
按行读取
样式丢失
面板类
执
默认参数值
trongLoop
ORA-00947
syslog
CASE的其它用法
杀掉进程
怎么锁定鼠标
Debian
应用图标
JS下载文件
mysql存储过程游
nextTick()
模板
triggerHandl
dbcp连接池
line-block
消息队列
获取网页源码
后面
如何
生命周期
服务器参数
TempDB
class.fornam
ADF
sd卡
实用教程
计算
赞助商链接
@CopyRight 2002-2008, 1SOHU.COM, Inc. All Rights Reserved QQ:1010969229