C# Static types cannot be used as parameters

前端 未结 8 2585
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 13:22
public static void SendEmail(String from, String To, String Subject, String HTML, String AttachmentPath = null, String AttachmentName = null, MediaTypeNames AttachmentTy         


        
8条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 13:47

    Send a static class as the type of the parameter and then give it a variable name for use in the function. This works because the new variable is a reference to the static class. It is necessary to address the global variable problem. If you use a static class as a variable inside a method, you need to pass it in as a parameter, to avoid the global variable issue. This is basic structured programming 101 from the 80's.

提交回复
热议问题