can someone convert this snipet of VB to c#?? Just Some Simple one (basics)

Hi

This shouldn`t be difficult .. but i dont know VB

But what does this means...

He declare a function named with "Afunction" and then in the body of that fucntion

he says.. Afunction= ..... LoL , how does he do that or what does that mean in c#

can a name of a function take some value

Please tell it what does this means in c#




Answer this question

can someone convert this snipet of VB to c#?? Just Some Simple one (basics)

  • Shelly Guo

    Actually it is quite different than return as it does not exit the function ... I can in fact set it multiple times

    {

    PV = 7

    //dosomething

    PV=12

    //do something else

    PV=23

    }


  • Asmenedas

    this goes back a ways in basic history ...

     

    FunctionName = value is similar to setting the return value of the function (without immediately returning).

    we often times end up with cases in C# where we do something like

    public int Bar() {
       int ret = 0;

    .

    .

    .

       return ret;
    }

    it offers the same functionality ...

    when the function is exiting it returns the value set.

    That particular code is functionally equivalent to ..

    Public Function FV(PV As Variant, i As Variant, n As Variant) As Variant

    {

         return PV * (1 + i / 100) ^ n

    }

    Cheers,

    Greg


  • J Bradley

    sure..

    sorry i`m not very good at explaining something i dont know.. here is the function

    Public Function FV(PV As Variant, i As Variant, n As Variant) As Variant

    {

    FV = PV * (1 + i / 100) ^ n

    }

    hmm. now you see .. how can a name of a function take a value lol.. Whats the equivelent in c#



  • Bhupathy Kandasamy

    hi,

    looool i don't know what do you talk about , i guess it will be better if you post the function here

    best regards



  • A9228356

    The statement

    FV = PV * (1 + i / 100) ^ n

    within body of the function "FV" is the same as

    return PV * (1 + i / 100) ^ n

    in VB or

    return PV * (1 + i / 100) ^ n;

    in C# :-)


  • sagesmith7

    loool .. very strange this VB

    it was very confusing.. for me.. Thanks!



  • Kervin

    Go look at the IL generated if you think the concept itself is strange! :)


  • Ori Lahav

    The statement

    FV = PV * (1 + i / 100) ^ n

    within body of the function "FV" is the same as

    return PV * (1 + i / 100) ^ n

    in VB or

    return PV * (1 + i / 100) ^ n;

    in C# :-)


  • Dagar

    No.

    Assignment to the function name in VB is just a 'feature' of VB which allows you to use the function name as a temporary variable. It is certainly *not* equivalent to 'return' since it does not trigger a return from the function. The temporary function name variable is just set and the function is not exited until it ends or an explicit 'Return' or 'Exit Function' is reached, at which point the current value of temporary function name variable is returned.

    David Anton
    www.tangiblesoftwaresolutions.com
    Instant C#: VB to C# Converter
    Instant VB: C# to VB Converter
    Instant C++: C# to C++ and VB to C++ Converter
    Instant J#: VB to J# Converter
    Clear VB: Cleans up VB code
    Clear C#: Cleans up C# code



  • can someone convert this snipet of VB to c#?? Just Some Simple one (basics)