I have an xml file:
<profiles>
<profile username="user4" fullname="Full Name" />
</profiles>
I am trying to retrive the value of the fullname, here is what I tried:
public List<string> GetFullName(string username)
{
List<Profile> list = null;
try
{
list = (from t in ProfileList
where t.UserName == username
select t).FirstOrDefault();
}
catch { }
List<string> userFullName = new List<string>();
if (list != null)
{
foreach (Profile t in list)
{
userFullName.Find(t.FullName);
}
}
return userFullName;
}
FirstOrDefault gives an error!
Thanks in advance.
FirstOrDefault gives an errorIs that all? What isProfileList? what error do you exactly get ?ProfileListtype can be inferred by us. It should beIEnumerable<T>whereThas a propertiesUserNameandFullName. ))