◎以上程式範例AspNet06.aspx,如在頁框下不能操作,請開新視窗操作
◎如果有問題歡迎您提出,dnowba很需要有人和我一起討論
Partial Class AspNet06 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' ===== 關於Null、Nothing、0、空值 的差別 ===== ' 這個部分其實我也不大懂,不過有幾篇相關文章 ' 就自已測試了一下,解釋的話不太會就是了 'http://www.cnblogs.com/zhanglinfan/articles/779924.html 'http://blog.csdn.net/lsf5921/article/details/4755723 Dim A Dim B As String Dim C As Integer Dim D As Object Me.Label1.ForeColor = Drawing.Color.Red Me.Label2.ForeColor = Drawing.Color.Green Me.Label3.ForeColor = Drawing.Color.Blue Me.Label4.ForeColor = Drawing.Color.Purple ' A 是不定型變數,所以應是Empty,預設被當作Object Me.Label1.Text = "Dim A" & " <br>A是否為Nothing:" & IsNothing(A) & "<br>A是否為Null:" & IsDBNull(A) ' B 已經定型,但尚未初始化,所以是 ""(空值) Me.Label2.Text = "Dim B As String" & "<br>B是否為Nothing:" & IsNothing(B) & "<br>B是否為Null:" & IsDBNull(B) ' C 已經定型,但尚未初始化,所以是 0 Me.Label3.Text = "Dim C As Integer" & "<br>C是否為Nothing:" & IsNothing(C) & "<br>C是否為Null:" & IsDBNull(C) ' D 尚未定義物件變數,所以是Nothing; Me.Label4.Text = "Dim D As Object" & "<br>D是否為Nothing:" & IsNothing(D) & "<br>D是否為Null:" & IsDBNull(D) End Sub End Class
沒有留言:
張貼留言