简体   繁体   中英

C# dynamic statement without dynamic keyword

I have a method that returns a string and takes a string:

public static string GenerateValidIdentifier(string token)
{
    using (var code = new CSharpCodeProvider())
    {
        return code.CreateValidIdentifier(token);
    }
}

and when I call it visual studios is saying that it is a dynamic statement, which I don't want. What's happening here?

CSharpCodeProvider is a method of CodeDomProvider, which is used to dynamically generate code, so it's usage can't be determined at compile-time (statically), so it is instead dynamic. Why are you using the method if it is not for dynamic programming?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM