"vb." <an*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
Why we give a function data type?
when we declare a function we gave a name and datatype for that function
what for? if i make a parameter i declare it and give it a datatype and if i use
variabels in function i daclare it too so what the use of datatype
function??
To prevent that you accidentally returning the wrong datatype (use 'Object'
if you need a Function that can return multiple datatypes)?
When you give a function in a Class a DataType, Code outside the Class that
calls the Function, can see What Datatype to expect in return from that
Function.
I guess that the Compiler could look at the code inside your Function and
see what DataType the Variable that returns a value got, but there might be
several
return-statements in a function. Witch one would be the correct one, and it
would require the Compiler to scan through you code ever time you made a
referance to a function, making it very inefficient and slow.