© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
46 replies
moshimoshi

❔ use of args in method

can someone explain the specific context in which we declare args in the methods?
e.g. for this method - no args are declared whereas for another mtd where new variables are introduced, args are declared.

Here's code:
public bool TransferTo(double amount, Account another)
    {
        bool isWithdrawOk = Withdraw(amount);

        if (isWithdrawOk)
        {
            another.Deposit(amount);
            return true;
        }
        else return false;
    }
public bool TransferTo(double amount, Account another)
    {
        bool isWithdrawOk = Withdraw(amount);

        if (isWithdrawOk)
        {
            another.Deposit(amount);
            return true;
        }
        else return false;
    }

public void CreditInterest()
    {
        var interest = CalculateInterest();
        Deposit(interest);
    }
public void CreditInterest()
    {
        var interest = CalculateInterest();
        Deposit(interest);
    }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ILogger<T> extension method "pass the args".
C#CC# / help
16mo ago
`args` used outside of the namespace
C#CC# / help
2y ago
✅ Use Roslyn to auto-generate overloads of method
C#CC# / help
3y ago
❔ Return in the middle of a method
C#CC# / help
3y ago