C # transpose the List of two-dimensional arrays and two-dimensional arrays & amp; lt; & amp; gt;

Source: Internet
Author: User

I just saw that in the previous article on the internet, SQL is used to transpose rows and columns. SQL server 2005/2008 uses only one commit function to implement complex implementations of SQL server 2000. When it comes to transpose, I immediately think of an exercise I have done at the school stage. I use C to implement the transpose of two-dimensional arrays. I believe everyone has done this exercise. The following uses the c # tool to implement it again without practical significance.

1. 2d array transpose

Code
Class Program
{
Public static string [,] Rotate (string [,] array)
{
Int x = array. GetUpperBound (0); // One-dimensional
Int y = array. GetUpperBound (1); // two-dimensional
String [,] newArray = new string [y + 1, x + 1]; // construct a transpose two-dimensional array
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 (
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.