0

I'm working on an audio tagger and one of its features is basically detecting if the checkbox with the tag name is checked and if the value in the textbox is changed.

This is the code I used so far:

if (chbAlbum.Checked == true && tbAlbum.Text != musFileTag.Album) { 
    fileStatus(3);
    tsbCloseFile.Enabled = false; 
} 
else {
    fileStatus(2); 
    tsbCloseFile.Enabled = true; 
}

now I'm switching to custom void:

void Checker(CheckBox chBox, TextBox tBox, String stringTag) {
    var musFileTag = TagLib.File.Create(musFileName).Tag;
    if (chBox.Checked == true && tBox.Text != musFileTag) { 
        return;
    }
}

how can I determine what tag it will be using from a string?

Normally to get an album tag I would use musFileTag.Album and for artist musFileTag.Performers but I need to determine the tag type from the string (something like musFileTag.{stringTag})

  • _how can I specify what tag it will be using from a string?_ - can you explain this a bit more? – stuartd Sep 15 '22 at 18:55
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 15 '22 at 21:03

1 Answers1

0

In the end, I used a switch:

Boolean Checker(String stringTag) {
       var musFileTag = TagLib.File.Create(musFileName).Tag;
       bool returningValue = false;

       switch (stringTag)
       {
           case "album":
               if(chbAlbum.Checked == true && tbAlbum.Text != musFileTag.Album) {returningValue = true; }
               break;
       }
}