[.NET] Return的作用?
之前練習用function時
對Return的理解是可以回傳某個值到某個變數
然後今天練習讀取文字時看到這串程式碼
Dim PATH As String = Console.ReadLine
Dim txt As New FileInfo(PATH)
Dim sr As StreamReader
Try
sr = txt.OpenText
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.ReadLine()
Return
End Try
然後我就不懂Return在這裡的意義了....
他回傳了什麼嗎
試著把它拿掉的話
之後在使用sr.peek時就會顯示在指派之前使用....可能會產生null參考例外
怕之前的理解有誤,所以想請問一下Return的確切意思和作用?
--
◢◣◢◣ ◢█ ◢█ ● ◢◣
◤█▊█ ◢◤█ ◢◤█◢ ◢ ◢◤
▊▊█◤ ◥██◣ ◥██◤ ◢█ ◥█◤
◢█ ◤█◤
◢◤█
◥█◤
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.196
推
05/23 12:55, , 1F
05/23 12:55, 1F