This documentation is archived and is not being maintained.

Compiler Error CS0269 

Error Message

Use of unassigned out parameter 'parameter'

The compiler could not verify that the out parameter was assigned a value before it was used; its value may be undefined when assigned. Be sure to initialize out parameters before accessing the value. If you need to use the value of the variable passed in, use a ref parameter instead. For more information, see Passing Parameters (C# Programming Guide).

Example

The following sample generates CS0269:

// CS0269.cs
class C
{
    public static void F(out int i)
    // Try this instead:
    // public static void F(ref int i)
    {
        int k = i;  // CS0269
        i = 1;
    }

    public static void Main()
    {
        int myInt;
        F(out myInt);
    }
}

This could also occur if the intitialization of a variable occurs in a try block, which the compiler is unable to verify will execute successfully:

// CS0269b.cs
class C
{
    public static void F(out int i)
    {
        try
        {
            // Assignment occurs, but compiler can't verify it
            i = 1;
        }
        catch
        {
        }

        int k = i;  // CS0269
        i = 1;
    }

    public static void Main()
    {
        int myInt;
        F(out myInt);
    }
}
Show: