1. <legend id='9jyUn'><style id='9jyUn'><dir id='9jyUn'><q id='9jyUn'></q></dir></style></legend>

      <tfoot id='9jyUn'></tfoot>
        • <bdo id='9jyUn'></bdo><ul id='9jyUn'></ul>

      1. <small id='9jyUn'></small><noframes id='9jyUn'>

        <i id='9jyUn'><tr id='9jyUn'><dt id='9jyUn'><q id='9jyUn'><span id='9jyUn'><b id='9jyUn'><form id='9jyUn'><ins id='9jyUn'></ins><ul id='9jyUn'></ul><sub id='9jyUn'></sub></form><legend id='9jyUn'></legend><bdo id='9jyUn'><pre id='9jyUn'><center id='9jyUn'></center></pre></bdo></b><th id='9jyUn'></th></span></q></dt></tr></i><div id='9jyUn'><tfoot id='9jyUn'></tfoot><dl id='9jyUn'><fieldset id='9jyUn'></fieldset></dl></div>

        Azure 函数 - 函数应该写在静态类中

        时间:2023-10-05
        • <i id='oCItH'><tr id='oCItH'><dt id='oCItH'><q id='oCItH'><span id='oCItH'><b id='oCItH'><form id='oCItH'><ins id='oCItH'></ins><ul id='oCItH'></ul><sub id='oCItH'></sub></form><legend id='oCItH'></legend><bdo id='oCItH'><pre id='oCItH'><center id='oCItH'></center></pre></bdo></b><th id='oCItH'></th></span></q></dt></tr></i><div id='oCItH'><tfoot id='oCItH'></tfoot><dl id='oCItH'><fieldset id='oCItH'></fieldset></dl></div>

              <tfoot id='oCItH'></tfoot>
              1. <small id='oCItH'></small><noframes id='oCItH'>

                  <tbody id='oCItH'></tbody>
                  <bdo id='oCItH'></bdo><ul id='oCItH'></ul>

                  <legend id='oCItH'><style id='oCItH'><dir id='oCItH'><q id='oCItH'></q></dir></style></legend>
                  本文介绍了Azure 函数 - 函数应该写在静态类中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我开始尝试 Azure 功能.我正在使用 Visual Studio 2017 预览版 15.3.当我右键单击我创建的 Azure Functions 项目并选择 Add>New Item...>Azure Function 时,Visual Studio 生成的默认模板是 public static classpublic静态异步任务方法(函数).

                  I'm starting to try out Azure functions. I'm using Visual Studio 2017 Preview version 15.3. When I right click on the Azure Functions project I created, and select Add>New Item...>Azure Function, the default template Visual Studio generates is of a public static class with a public static async Task method (the function).

                  该类是否需要是静态的(我将其更改为非静态的,它似乎可以工作)?这是 Azure 函数的最佳实践吗?如果是这样,使用非静态类来保存 Azure Function 方法可能会出现什么问题?

                  Does the class need to be static (I changed it to non-static and it seems to work)? Is that a best practice for Azure functions? If that is the case, what problems might rise by using a non-static class to hold the Azure Function method?

                  推荐答案

                  该类是否需要是静态的(我将其更改为非静态的,它似乎可以工作)?这是 Azure 函数的最佳实践吗?

                  Does the class need to be static (I changed it to non-static and it seems to work)? Is that a best practice for Azure functions?

                  静态类只能包含静态成员,不能实例化.将类更改为非静态将允许您添加非静态成员并创建此类的实例.

                  A static class can only contain static members, and it can't be instantiated. Changing the class to non-static will allow you to add non-static members and create an instance of this class.

                  请检查您是否需要向此类添加非静态成员或创建此类的实例.由于单一职责原则,即每个类都应对软件提供的单个功能部分负责,我建议您创建一个新类并将非静态成员放在那里.

                  Please check whether you need to add non-static members to, or create an instance of, this class. Due to the Single Responsibility Principle, which states that every class should have responsibility over a single part of the functionality provided by the software, I suggest you create a new class and put the non-static members there.

                  如果是这样,使用非静态类来保存 Azure Function 方法可能会出现什么问题?

                  If that is the case, what problems might rise by using a non-static class to hold the Azure Function method?

                  我想你想使用非静态类的原因是你想在其中创建一些非静态成员.这样做会使您的类变得复杂且难以维护.

                  I suppose the reason you want to use a non-static class is that you want to create some non-static members in it. Doing so will make your class complex and difficult to maintain.

                  我的最终答案是该类可以更改为非静态的.为了保持类简单,我建议你保持类静态.

                  My final answer is that the class can be changed to non-static. To keep the class simple, I suggest you keep the class static.

                  这篇关于Azure 函数 - 函数应该写在静态类中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 C# 从 Azure Blob 复制到 AWS S3 下一篇:如何将 appsettings.json 文件添加到我的 Azure Function 3.0 配置?

                  相关文章

                  <i id='2w64g'><tr id='2w64g'><dt id='2w64g'><q id='2w64g'><span id='2w64g'><b id='2w64g'><form id='2w64g'><ins id='2w64g'></ins><ul id='2w64g'></ul><sub id='2w64g'></sub></form><legend id='2w64g'></legend><bdo id='2w64g'><pre id='2w64g'><center id='2w64g'></center></pre></bdo></b><th id='2w64g'></th></span></q></dt></tr></i><div id='2w64g'><tfoot id='2w64g'></tfoot><dl id='2w64g'><fieldset id='2w64g'></fieldset></dl></div>

                    <bdo id='2w64g'></bdo><ul id='2w64g'></ul>
                  1. <tfoot id='2w64g'></tfoot>

                    <legend id='2w64g'><style id='2w64g'><dir id='2w64g'><q id='2w64g'></q></dir></style></legend>
                    1. <small id='2w64g'></small><noframes id='2w64g'>