any equivalent to VB.net function name as return value in C#?
Posted
by
user1179861
on Stack Overflow
See other posts from Stack Overflow
or by user1179861
Published on 2012-11-04T10:58:41Z
Indexed on
2012/11/04
10:59 UTC
Read the original article
Hit count: 236
In vb.net there is a weird approach that you can use the function name as the result variable..
example:
Function Foo(ByVal bar As Integer) As List(Of Integer)
Foo = New List(Of Integer)
Foo.Add(bar + 1)
End Function
As far as i know, in C# you have to:
List<int> foo(int bar)
{
var result = new List<int>();
result.Add(bar + 1);
return result;
}
I'm not sure if it's by design or i just don't know the right way to do this.. Please enlight me!
Thanks in advance, Eitan.
© Stack Overflow or respective owner