Home >Backend Development >C++ >Can C# Call a Function from a String?

Can C# Call a Function from a String?

DDD
DDDOriginal
2025-01-26 02:09:08412browse

Can C# Call a Function from a String?

In the string call function

PHP can call the function by the function name stored in the string. For example:

.NET can achieve this function?
<code class="language-php">$function_name = 'hello';
$function_name();

function hello() { echo 'hello'; }</code>

Yes.

It can be used to achieve this function. The method is as follows:

Please note that the method of being called must have a public access decoration. For non -public methods, please use bindingflags parameters:

The above is the detailed content of Can C# Call a Function from a String?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn