VB.NET me agar hum return type function ki return statement nahi mention krte ya kuch bhi return nahi krwatey to by-default VB.NET ka compiler aik 'NEW OBJECT' return krwaye ga, is ka matlab yeh hua k memory me aik 'NEW OBJECT' create hoga aur woh return ho jaye ga aur yeh object empty hoga, yeh cheez VB.NET me 'Runtime error' kehlaye gi jab k C# me yeh cheez 'Compile-time error' k tor pe show hogi. Yehi wajah hai k VB.NET 'Loosly coupled language' hai aur C# 'Tightly coupled language' hai.
Example Code of VB.NET (Module1.vb) | |
---|---|
1 | Module |
2 | Sub Main() |
3 | Console.Write(Add(1,1)) |
4 | Console.ReadLine() |
5 | End Sub |
6 | Function Add(i AS Integer, j AS Integer) AS Long |
7 | Return i+j |
8 | End Function |
9 | End Module |
No comments:
Post a Comment