Saturday, August 19, 2017

Out keyword in c#

Out is a keyword that uses for passing the arguments by reference. Out keyword is like a ref keyword. In ref, keyword variable requires being initialized before it passed. Use out keyword both methods need to be initialized or we can say email sender and receiver both need the same headline.


class Example
        static void Method(out int i, out string s1)
            i = 420;
            s1 = "I hate u";
        static void Main()
            int value;
            string str1;
            Method(out value, out str1);

No comments:

Post a Comment