It depends on your precise needs. Two ways I can think of:
Use a language like Python which is interoperable with C#, and call the Python script from C#. Actually, you can even make things simpler by just calling an executable, passing to it an XML or JSON data, and wait for XML or JSON response.
If you need to use C#, then compile C# on the fly, just like LINQPad does. Is it possible to dynamically compile and execute C# code fragments?Is it possible to dynamically compile and execute C# code fragments? is a good starting point. Loading the code in a sandbox (in a different
AppDomain) is also a good idea if you need to provide enough security and don't trust the code which can be written by the user.