C# (Sharp) Programming Language Question:

I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?

Tweet Share WhatsApp

Answer:

You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows:
[return-type] foo(out int o) { }

Download C# (Sharp) Programming Language PDF Read All 163 C# (Sharp) Programming Language Questions
Previous QuestionNext Question
If I return out of a try/finally in C#, does the code in the finally-clause run? How does one compare strings in C#?