**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
昨天关门了。
Improve this question
这是我的模型
using System;
using Newtonsoft.Json;
using Xamarin.Forms;
namespace AMIMobile
{
public class LoginItemsModel
{
[JsonProperty("userid")]
public long Userid { get; set; }
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("password")]
public object Password { get; set; }
[JsonProperty("fullname")]
public string fullname { get; set; }
[JsonProperty("roleid")]
public long Roleid { get; set; }
[JsonProperty("role")]
public object Role { get; set; }
[JsonProperty("status")]
public long Status { get; set; }
[JsonProperty("logfail")]
public object Logfail { get; set; }
[JsonProperty("expire")]
public string Expire { get; set; }
[JsonProperty("lastlog")]
public string Lastlog { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("phone")]
public string Phone { get; set; }
[JsonProperty("visiblp")]
public string Visiblp { get; set; }
[JsonProperty("peaid")]
public object Peaid { get; set; }
[JsonProperty("posifull")]
public object Posifull { get; set; }
[JsonProperty("posiabbr")]
public object Posiabbr { get; set; }
[JsonProperty("deptfull")]
public object Deptfull { get; set; }
[JsonProperty("deptabbr")]
public object Deptabbr { get; set; }
[JsonProperty("deptarea")]
public object Deptarea { get; set; }
[JsonProperty("accesstoken")]
public string Accesstoken { get; set; }
[JsonProperty("clientinfo")]
public object Clientinfo { get; set; }
[JsonProperty("devicename")]
public object Devicename { get; set; }
[JsonProperty("platform")]
public object Platform { get; set; }
[JsonProperty("iS_REMEMBERME")]
public bool ISRememberme { get; set; }
[JsonProperty("magerror")]
public string Magerror { get; set; }
[JsonProperty("statuscode")]
public long Statuscode { get; set; }
[JsonProperty("iS_ERRORSTATUS")]
public bool ISErrorstatus { get; set; }
public string FullName
{
get { return Username; }
}
public string FirstName { get; set; }
}
}
and this is my view model
public class LoginViewModel : INotifyPropertyChanged
{
// For data binding of activity indicator
private ObserverableCollection<LoginItemsModel> _fn;
private ObserverableCollection<LoginItemsModel> Fullname
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChange([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
'这显示了属性或索引器必须至少有一个访问器错误我不知道这是什么请帮助我如何修复它们,我的错误在
private ObserverableCollection<LoginItemsModel> Fullname
{
}
,我为xamarin移动的应用程序编写C#我是C#新手
我想知道如何修复这个错误,我谷歌这个错误,但我没有找到如何修复这个,我尝试绑定这个形式谷歌和它显示错误对不起我的英语
2条答案
按热度按时间but5z9lq1#
The meaning of this code
is - configure a private property (getter and or setter), just like your
LoginItemsModel
hasif you want to define
Fullname
as private member just do thisand if you want to make it a property - add at least a
getter
(seems logical to your use case)bksxznpy2#
From the C# programming guide :
A Property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Properties can be used as if they're public data members, but they're special methods called accessors. This feature enables data to be accessed easily and still helps promote the safety and flexibility of methods.
In your
ViewModel
, the propertyFullname
does not have a property accessor. This throws the error Compiler Error CS0548 .You probably wanted to do something like this:
Side note: Usually, properties are
public
members. Yours is set toprivate
. Was this a design decision?