if statement - Is there a shortened method to loop through conditions in IF in VB.NET -


so making program needs check if file of video / audio format. have code (song system.io.fileinfo):

if song.extension.toupper = ".mp4" or song.extension = ".avi" or song.extension = ".mp3" or song.extension = ".aa" or song.extension = ".m4a" or song.extension = ".aiff" or song.extension = ".wav" or song.extension = ".m4v" or song.extension = ".aac" or song.extension = ".vob" 

the problem checks first 2 conditions. need split separate ifs or there way test conditions in 1 line?

you can make set extensions in it:

dim extensions new hashset(of string) {     ".mp4", ".avi", ".mp3", ".aa", ".m4a", ".aiff", ".wav",     ".m4v", ".aac", ".vob" } 

and check if value in contains:

if extensions.contains(song.extension.tolower())     ⋮ end if 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -