Xamarin 为什么我的对象在有值时仍然为空?
我试着显示投票数 在我的itemDetails页面中,我从items页面接收我的数据所有我的数据都是可读的,但字符串标题、字符串描述、int投票当我单击我的按钮访问items details页面时,我接收到错误对象null,当我试图读取INT时,我试图进入try.parse或多种转换解决方案,但我找不到不好的文字 多谢各位Xamarin 为什么我的对象在有值时仍然为空?,xamarin,visual-studio-2017,nullreferenceexception,Xamarin,Visual Studio 2017,Nullreferenceexception,我试着显示投票数 在我的itemDetails页面中,我从items页面接收我的数据所有我的数据都是可读的,但字符串标题、字符串描述、int投票当我单击我的按钮访问items details页面时,我接收到错误对象null,当我试图读取INT时,我试图进入try.parse或多种转换解决方案,但我找不到不好的文字 多谢各位 FirebaseHelper firebaseHelper = new FirebaseHelper(); public ItemDetailsPage(string Ti
FirebaseHelper firebaseHelper = new FirebaseHelper();
public ItemDetailsPage(string Titre, string Description, int Vote)
{
InitializeComponent();
MyTitre.Text = Titre;
MyDescription.Text = Description;
MyVote.Text = Vote.ToString();
}
也许删除MyVote前面的空格可以解决这个问题
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name="MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
你能告诉我怎么称呼ItemDetailsPage吗?另外,您从何处获得NullReferenceException?当我添加行MyVote.Text=Vote.ToString时,将显示我的null引用;如果不是,工作是否完美?哪个对象为空?MyVote还是Vote?我不知道,我也不知道如何知道我刚刚遇到了一个带有空引用消息的崩溃。我的投票。文本就像我的重新编辑帖子哦,我的上帝,我在这个F。。。。错误持续了48个小时,我甚至没有睡觉,因为这个。。。谢谢你,谢谢你,你拯救了我期待已久的睡眠之夜。
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name=" MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name="MyVote" d:Name="Name!"
BackgroundColor="Gray"/>