c# - Removing element from array: convert to list, remove element, convert back to array? -


in program have class called album. have array album objects go on creation. need let user change albumname of album later if want to. need let user delete albums array if want to. understand, can't delete objects arrays, if stored in list, not array.

from understand of lists (i haven't used them before this), can't put album objects list instead of array on creation if want change variable in album object later. can't delete , replace album object new 1 in list if want change albumname, since album object storing array (mymusics) lost if did that.

so question is, how allow user make changes album objects while letting them delete them? think i'd have change array stored in, list. delete object fromt list, change list same array. correct? how if right way go this?

also, if helps/makes difference, array containing albums created in form1, album objects deleted form 1, changes albumname in album object happen in form2.

any appreciated. i'm pretty new using c#, example of code me understand fantastic. thank you.

album class:

public class album {     public string albumname;     private int totalmusics;     private const int max_musics = 100;     private music[] mymusics;      public album(string albumname)     {         this.albumname = albumname;         totalmusics = 0;         mymusics = new music[max_musics];     } } 

from understand of lists (i haven't used them before this), can't put album objects list instead of array on creation if want change variable in album object later.

this true structs. since using (mutable) class, able change properties of objects while stored in list<album>.

so definitely should using list.

unless want able albums field, example albumname. if so, use dictionary<string, album> , use albumname key.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -