Real-world examples where C# 'out' parameters are useful?

后端 未结 8 884
逝去的感伤
逝去的感伤 2020-12-29 06:46

I\'m reading up on core C# programming constructs and having a hard time wrapping my head around the out parameter modifier. I know what it does by reading but

8条回答
  •  无人及你
    2020-12-29 07:02

    //out key word is used in function instead of return. we can use multiple parameters by using out key word
    public void outKeyword(out string Firstname, out string SecondName)
    {
        Firstname = "Muhammad";
        SecondName = "Ismail";
    
    }
    //on button click Event
    protected void btnOutKeyword_Click(object sender, EventArgs e)
    {
        string first, second;
        outKeyword(out first, out second);
        lblOutKeyword.Text = first + "  " + second;
    }
    

提交回复
热议问题