3
In C#, this code does not compile:
public static string Teste(){
string val = "";
return val.Trim;
}
Because the function Teste
requires a return of the type string
, and Trim
is a MethodGroup
. That makes perfect sense in my opinion.
However, in VB.NET, this function works perfectly:
Public Function Teste() as String
Dim valor as String = ""
Return valor.Trim
End Function
Why does calling functions in VB not need parentheses? Can I pass parameters for functions invoked in this way? After all, there is a difference between calling with or without parentheses?