【发布时间】:2017-01-22 16:54:15
【问题描述】:
我正在制作一个应用程序来编辑 .mp3 文件的属性。我不得不说我对编程和 stackoverflow 还很陌生,所以我可能会做一些非常明显错误的事情。请原谅我!这是我正在使用的代码:
private void btnApply_Click(object sender, EventArgs e)
{
var file = TagLib.File.Create(filepath);
if (!string.IsNullOrWhiteSpace(txtGenre.Text))
{
file.Tag.Genres = new string[] {txtGenre.Text};
}
if (!string.IsNullOrWhiteSpace(txtArtist.Text))
{
file.Tag.Performers = new string[] {txtArtist.Text};
}
if (!string.IsNullOrWhiteSpace(txtTitle.Text))
{
file.Tag.Title = new string[] {txtTitle.Text};
}
file.Tag.Performers = new string[] { txtArtist.Text };
file.Tag.Title = txtTitle.Text;
file.Save();
if (!ReadFile())
{
Close();
}
}
对我来说奇怪的是,我只收到这部分的错误:
if (!string.IsNullOrWhiteSpace(txtTitle.Text))
{
file.Tag.Title = new string[] {txtTitle.Text};
}
红色下划线:
new string[] {txtTitle.Text}
我在这里缺少什么?我一直在寻找很长时间,但我似乎无法找到任何解决方案。先感谢您!顺便说一句,我也在使用 TagLib。
【问题讨论】:
-
你了解
string和string[]的区别吗? -
您正试图将
string[]值放入string变量中。file.Tag.Title是string -
你可以试试:
file.Tag.Title = txtTitle.Text; -
@Luctia 请不要用“SOLVED:”之类的状态信息破坏问题标题。接受答案就是为了这个目的。