Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameter as final in C#

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
}
like image 506
Ravisha Avatar asked Apr 16 '10 07:04

Ravisha


People also ask

What is passing parameters in C?

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.

How many ways pass parameters in C?

There are two ways to pass parameters in C: Pass by Value, Pass by Reference.

What are the two different types of parameter passing?

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.

Can you pass functions as parameters in C?

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.


1 Answers

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)?

like image 58
Oded Avatar answered Sep 21 '22 05:09

Oded