Differences between array declarations

2

What's the difference between declaring an array like this:

 'C#
 string MinhaMatriz[] = []
 'VB
 Dim MinhaMatriz() As String = { }

and so:

 'C#
 string[] MinhaMatriz = []
 'VB
 Dim MinhaMatriz As String() = { }

or so:

 'C#
 System.Array<string> MinhaMatriz
 'VB
 Dim MinhaMatriz As System.Array(Of String)
    
asked by anonymous 26.06.2015 / 23:09

2 answers

3

Essentially the differences are syntactic. That is, it makes no difference to the program how you make the statement.

Note that in C # only the second form is actually valid. In fact, neither it, in the way described, after all, does not exist the literal [] to array .

The third way does not work this way even in VB.Net. System.Array is not the same type as array and it does not have a generic version as a proposal. It has some tricks to simulate this but I think it is beyond the scope of the question.

    
07.07.2015 / 06:06
1

There is a difference between a list and an array. Its basic functions are practically the same, but the Lists ( List<T> ) I, in particular, find more powerful and are more used.

// um array é declarado da seguinte forma:
string[] MeuArray = new string[5];



// Uma lista de objetos List<T> é declarado da seguinte forma
List<String> MinhaLista = new List<String>();
  • I do not know this statement style " string MinhaMatriz[] = [] "
27.06.2015 / 21:38