Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8283673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:49:05+00:00 2026-06-08T10:49:05+00:00

Function parameters tend to have different purposes : in most case they are just

  • 0

Function parameters tend to have different purposes : in most case they are just readonly indications used by the internal logic to produce a result/effect, but sometimes they are modified by the calling function (initialisation function, sorting algorithm etc).

I was wondering if there is a best practice to show in the code that the function is going to modify a parameter (apart from writing a comment above stating this explicitly)? Like a widely recognized coding convention.

With C++ I use the ‘const’ keyword for every parameter which is not going to be modified by the function, but C# does not allow const or ‘readonly’ to be used that way. And a lack of ‘const’ does not really mean that the parameter is intended to be updated by the function anyway.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:49:08+00:00Added an answer on June 8, 2026 at 10:49 am

    Actually in C# valued-type parameters (and strings, due to immutability) are “const” by default, unless you explicitly mark them with out or ref keywords. As for reference types function can only modify object that the parameter refers to, not the reference itself.

    Moreover, those out and ref keywords are hints for compiler, that analyzes the flow of code and dissallows use of “uninitlized” variables. So. i.e. if you declare method:

    void DoSomething(int i) { ... }
    

    and then try calling it from the following code:

    int x;
    DoSomething(x);
    

    the compiler will disallow, as x will be uninitialized at the time of call. On the other hand:

    void DoSomething(out int i) { ... i = 10; ... }
    

    the following call is now allowed:

    int x;
    DoSomething(out x);
    

    as compiler now knows that DoSomething is going to initialize x. Notice, that DoSomething won’t compile unless it containts a statament, that assigns some value to i parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question regarding the use of function parameters. In the past I have
What is the meaning of these keywords used before variables in a function parameters?
How to call function using parameters in powershell with parenthesis. I have as example
I have the following function //simple function with parameters and variable function thirdfunction(a,b,c,d){ console.log(the
Is there a way to have default function parameters in C# like we have
My question is related to C# function parameters. I'm used to C++ where parameters
What are current_user_can() function parameters ? This function is used in wordpress script, I
Previously, I'd just dealt with these types of __out function parameters using malloc, but
I have a function for which I cannot change the function parameters. I need
How can i get a lambda list specification of a some function parameters, or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.