It looks like you want something along the lines of
eval() support for running Apex code from .NET and then getting the result back.
I've covered this from the perspective of Apex-to-Apex, but the principal is the same. Kevin also has an alternative approach with a similar goal.
The trick in both approaches is that executing anonymous apex doesn't have a direct mechanism for returning a result. You either need to deliberately throw an exception with the value you want back or return it in the debug log that gets generated. Then you do a bit of parsing to pull your result out.
To your specific example, you have an Id and you want to know metadata about the associated sObject?
There are much easier ways to do this than executing anonymous apex and parsing the result out and all the associated problems.
The Partner API provides a large amount of metadata about the sObjects that are accessible by the current user.
- Extract the key prefix from the first 3 characters of the ID you have. See What are Salesforce ID's composed of?
- Call describeGlobal() to figure out which sObjects you can access.
- Scan through the returned DescribeGlobalSObjectResult collection looking at the keyPrefix field. When you find a match you will have some basic initial metadata, such as the sObject label and API name.
- Call describeSObjects() is you want some richer DescribeSObjectResult metadata.