'MyObject' не содержит определения для - C#
Формулировка задачи:
Есть класс:
И есть метод в другом классе:
Не понимаю, почему в строках
и
Ошибка:
"Song" не содержит определение для "Song". Не удалось найти метод расширения "Song", принимающий первый аргумент типа "Song" (пропущена директива using или ссылка на сборку?)
Свойства же объявлены, get прописан. В чем дело? В сериализации? Да вряд ли.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace radio.Models
{
[Serializable]
public class Song
{
[XmlAttribute]
public int ID { get; set; }
[XmlAttribute]
public string Name { get; set; }
[XmlAttribute]
public string Artist { get; set; }
[XmlAttribute]
public int Duration { get; set; }
[XmlAttribute]
public string Album { get; set; }
[XmlAttribute]
public int Year { get; set; }
[XmlArrayItem(Type = typeof(Tag))]
public List<Tag> Tags { get; set; }
[XmlArrayItem(Type = typeof(Genre))]
public List<Genre> Genres { get; set; }
[XmlIgnore]
public string Path { get; set; }
[XmlIgnore]
public string StringDuration
{
set { StringDuration = value; }
get { return getStringDuration(Duration); }
}
public Song() { }
public Song(int ID, string Name, string Artist, int Duration, List<Tag> Tags, List<Genre> Genres, int Year)
{
this.ID = ID;
this.Name = Name;
this.Artist = Artist;
this.Duration = Duration;
this.Tags = Tags;
this.Genres = Genres;
this.Year = Year;
}
public override string ToString()
{
return Name;
}
}
}public ObservableCollection<Song> Search<Song>(SearchParams searchParams, ObservableCollection<Song> listToSearch)
{
List<Song> searchResults = new List<Song>();
foreach (Song song in listToSearch)
{
if (song.Name.ToLower().Equals(searchParams.Name.ToLower()))
{
searchResults.Add(song);
}
}
ObservableCollection<Song> listItems = listToSearch.Where(i => i.Song == searchParams.Name);
return null;
}if (song.Name.ToLower().Equals(searchParams.Name.ToLower()))
i => i.Name == searchParams.Name
Решение задачи: «'MyObject' не содержит определения для»
textual
Листинг программы
public ObservableCollection<Song> Search(SearchParams searchParams, ObservableCollection<Song> listToSearch)