tags:

views:

283

answers:

1

How would I get this to work? Looking to have result updated with the 100 using generic typing. Any ideas? Of course this function isn't complete, I just need to get the result functionality working so I can continue.

    public static bool ReadMemory<T>(Process process, IntPtr address, ref T result)
    {
        Type objType = result.GetType();

        switch (objType.Name)
        {
            case "Int32":
                result = (T)100;
                return true;
            default:
                return false;
        }
    }
+1  A: 

i would actually refactor this and return the result. i would throw an exception if the switch or if/else locks fell through to the bottom of the method. You could then catch the failure in try/catch in the client code.

Paul Sasik