Null reference error in foreach statement
I am getting a null reference error in the below code:
string artistName =
mov.get_Annotation((int)QTAnnotationsEnum.qtAnnotationArtist);
string albumName =
mov.get_Annotation((int)QTAnnotationsEnum.qtAnnotationAlbum);
string songTitle =
mov.get_Annotation((int)QTAnnotationsEnum.qtAnnotationFullName);
foreach (char c in artistName)
{
artistName = artistName.Replace("?", "");
artistName = artistName.Replace("*", "");
artistName = artistName.Replace("/", "");
artistName = artistName.Replace(":", "");
}
foreach (char c in albumName)
{
albumName = albumName.Replace("?", "");
albumName = albumName.Replace("*", "");
albumName = albumName.Replace("/", "");
albumName = albumName.Replace(":", "");
}
I have copied this code from another persons project and though I mostly
understand what is happening I cannot figure out the error. The error is
on the for each (char c in artistName) line. Thanks for any help.
No comments:
Post a Comment