小编use*_*891的帖子

具有out参数的静态方法是否安全?

基本上,我有一些类调用静态void提供了参数(used in an ASP website).

从我的理解,因为虚空有它自己的堆栈它是线程安全的,但是我不完全确定在使用输出时是否为真.有人可以澄清这个问题.谢谢!

namespace ThreadTest
{
class Program
{
    static void Main(string[] args)
    {
        int helloWorldint = 0;
        bool helloWorldbool = false;

        int helloWorldintOut = 0;
        bool helloWorldboolOut = false;

        setHelloWorlds(helloWorldint, helloWorldbool, out helloWorldintOut, out helloWorldboolOut);


        Console.WriteLine(helloWorldintOut);
        Console.WriteLine(helloWorldboolOut);
    }

    public static void setHelloWorlds(int helloWorldint, bool helloWorldbool, out int helloWorldintOut, out bool helloWorldboolOut)
    {

        helloWorldintOut = helloWorldint + 1;
        helloWorldboolOut = true;

    }
}
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net

7
推荐指数
1
解决办法
1116
查看次数

标签 统计

asp.net ×1

c# ×1