In C #, this code does not compile:
public static string Teste(){
string val = "";
return val.Trim;
}
Because the Teste
function requires a return of 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 invocation of functions in VB does not need parentheses? Can I pass parameters to functions invoked in this way? After all, is there a difference between invoking with or without parentheses?