vb.net - Specifying return type of a Public Function is necessary or not? -


I have a snippet here:

  dimmed as an integer = 10 & Lt; - - 10A = bioferonephone (A) '& lt; --- Calling the calling function and assigning return value is a functional variable by function F integer = 30 '& lt; - 30 return to function calling function  

They do not have any return type specified in the function but it works fine and return integer and string value;

My Question is that it is necessary to specify the return type of public function or not? Or cause the function to return the value

This is necessary in this sense It is not that you can close the option strictly, but it is considered the worst practice to tighten the option (unless you do not know why you are doing this ...)

If you decide to strictly close the option and add it as a section on your function, then your function is an 'o' Junk 'will return, which is obtained from the base objects, and you can type to type that object you are typing it to.

The only problem is if your The function returns an object, and that object is of the "string" type, then when you specify the output of your function in an integer, the compiler will not show any errors until runtime, you will get an invalid Contrast, exceptions will.

Example:

  sub-council () Due to the result of integer = GetCalculation () end subfunction GetCalculation () "Hello" Return the world "end function  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -