使用LINQ查询时,类具有无效的表达式术语"from"

Car*_*ras 4 c# linq serialization

我有以下可序列化的类:

[Serializable]
public class EmailClass
{
    public string from;
    public List<string> To;
    public List<string> CC;
    public string DisplayTo;
    public string Subject { get; set; }
    public int attachments;      
    public List<string> attachmentsName;
    public string DateTimeReceived;
    public string DateTimeSent;
    public string FinalFilename;
    public string DatetimeCreated;
    public string ExchangeUniqueId;
    public string ChankeyID;
    public string  FinalFileName {get;set;}
    public bool Encrypted;
    public string Descripcion { get; set; }

}
Run Code Online (Sandbox Code Playgroud)

所以知道,我有一个List,我想使用Linq查询它:

 var query = from p in listado 
             where p.from.ToString().ToUpper() == textBox1.Text
Run Code Online (Sandbox Code Playgroud)

问题是它p.from 从标识符中识别为linq,因此不被接受.

错误:无效的表达式术语'from'

无法更改类公共字符串"from",因为它反序列化存储在硬盘中的xml对象.

我怎么能解决这个问题?

我知道我可以使用List.FindAll或类似的东西,但我真的想知道我是否可以使用linq.

Dav*_*rno 8

更改where p.from.ToString()where p.@from.ToString().您将from同时用作关键字和标识符.