c# - Does assigning an non-empty array to another array clear the array? -


say have arrays,

        string[] arr1 = { "hi", "hello", "goodbye" };         string[] arr2 = { "stop", "making", "arrays", "please" };         string[] arr3 = { "simple", "array"}; 

according declaration above arr1 initialized size 3, arr2 4, , arr3 2. arr1 has been initialized array maximum size 3, happens if assign different array it?

  • are original values cleared , replaced new array?
  • what if second array smaller, values smaller array populated , old values kept?
  • if it's bigger, indexoutofrange exception?

the variables pointers arrays. assigning arr2 arr1, arr1 , arr2 both point { "stop", "making", "arrays", "please" }. if assign "test" arr1[1], arr2[1] == "test". original array assigned arr1 orphaned , garbage collected @ point.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -