This might be a duplicate question.But could not find it in search In java to mark a method parameter as constant we declare it as final whats the equivalent C# keyword? Like
public void doSomeThing(final object myObject)
{
//print myobject
}
Parameter passing involves passing input parameters into a module (a function in C and a function and procedure in Pascal) and receiving output parameters back from the module. For example a quadratic equation module requires three parameters to be passed to it, these would be a, b and c.
There are two ways to pass parameters in C: Pass by Value, Pass by Reference.
Formal Parameter : A variable and its type as they appear in the prototype of the function or method. Actual Parameter : The variable or expression corresponding to a formal parameter that appears in the function or method call in the calling environment.
In C programming you can only pass variables as parameter to function. You cannot pass function to another function as parameter. But, you can pass function reference to another function using function pointers.
This is not possible in C# - there is no way to mark a passed in parameter as a constant.
If you have a const
that needs to be available to many functions, why not declare it with the right scoping (class scoping or global if needed)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With