It's Possible now with ASP.Net MVC4 Razor
View engine. the code will be this:
// c# class
public class A
{
public string Hello(string msg)
{
return msg + " whatewer";
}
}
// js snippet
<script type="text/javascript">
var a = new A();
console.log('@a.Hello('Call me')'); // i have a console.log implemented, don't worry, it's not a client-side code :)
</script>
and Razor
isn't just for MVC4 or another web applications and you can use it in offline desktop applications.