gpt4 book ai didi

c# - visual studio 中的 nullreferenceexception

转载 作者:太空宇宙 更新时间:2023-11-03 22:11:14 25 4
gpt4 key购买 nike

<分区>

我的代码中出现 NullReferenceException。

我从同一项目中的另一个页面调用方法 datecheck 并将两个字符串作为参数传递。这些包含用户以字符串格式选择的日期。现在,当我尝试使用这些字符串值初始化 2 个标签 label1 和 label2 时,我得到了 NullReferenceException。

显示错误和堆栈跟踪的代码行如下:

Line 39:         public void datecheck(String s1, String s2)
Line 40: {
Line 41: Label1.Text = s1;
Line 42: Label2.Text = s2;
Line 43: }

源文件:I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking Status.aspx.cs 行:41

堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.]
GuestHouseApp.Booking_Status.datecheck(String s1, String s2) in I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking Status.aspx.cs:41
GuestHouseApp.Booking.Button1_Click(Object sender, EventArgs e) in I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking.aspx.cs:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +113
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5348

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com