'Assign values to ssis variable

I am trying to assgin a value to a variable in script component using C# but unable to do so. Can anyone please post the code or tell me what wrong below.

public override void PostExecute()

    base.PostExecute();
    IDTSVariables100 varCollection = null;
    this.VariableDispenser.LockForWrite("User::Variable");
    this.VariableDispenser.GetVariables(out varCollection);

    varCollection["User::Variable"].Value = @"TESTING";
    MessageBox.Show(Variables.MerchOrgName.ToString());


Solution 1:[1]

This example is very comprehensive. Most of the time the easier of the two methods is sufficient - especially if you are just starting.

http://microsoft-ssis.blogspot.com/2011/01/how-to-use-variables-in-script.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anoop Verma