How can create Array in VB.Net & C# ?

ms_visual_studio    There are different ways that you can create array , here I am going to explain them for you
1.You can supply the array size when you are declaring it , as the following example shows.

[VB.NET]

        Dim cargoWeights(10) As Double 

        Dim atmospherePressures(2, 2, 4, 10) As Short 

        Dim inquiriesByYearMonthDay(20)()() As Byte

[C#]

        double[] cargoWeights = new double[11];

        short[,,,] atmospherePressures = new short[3, 3, 5, 11];

        byte[][][] inquiriesByYearMonthDay = new byte[21][][];

2.You can also use a New clause to supply the size of an array
 when it’s created, as the following example shows.

[VB.NET]

          cargoWeights = New Double(10) {}

          atmospherePressures = New Short(2, 2, 4, 10) {}

          inquiriesByYearMonthDay = New Byte(20)()() {}

[C#]

          cargoWeights = new double[11];

          atmospherePressures = new short[3, 3, 5, 11];

          inquiriesByYearMonthDay = new byte[21][][];


Categories: .Net

Tags: , , , ,

2 replies

  1. I really like it when folks get together and share opinions.
    Great website, keep it up!

  2. Its not my first time to visit this website, i am visiting this site dailly and take fastidious facts
    from here everyday.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: