Probably your best option would be to hide the code in a static class. something like this should work:
public static class HexAdder
{
private static UInt32 num1 = 0, num2 = 0;
private static void ParseString(string stringtoadd)
{
string[] temp = {"",""};
try
{
temp = stringtoadd.Split(" +".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
num1 = Convert.ToUInt32(temp[0], 16);
num2 = Convert.ToUInt32(temp[1], 16);
}
catch(Exception e)
{
MessageBox.Show("Invalid String Format\n- Added String = " + stringtoadd + "\n- First Part = " + temp[0] + "\n- Second Part = " + temp[1]);
}
}
public static UInt32 AddedToUint32(string stringtoadd)
{
ParseString(stringtoadd);
return num1 + num2;
}
}
This has basic validation and pops up a messagebox and returns 0 if there is an error.
Using it would look like this:
string test = "0x83e3ba3c + 0x15";
UInt32 example = HexAdder.AddedToUint32(test);
This way adding other operations is a simple matter of adding the appropriate static method(s).