Comparing .NET Strings and JavaScript Strings

Question in short:

How do I compare a .NET String object with a JavaScript string or better yet: convert the one into the other?


I have a C# class handling tcp/ip socket connections. You can register functions with the class that handle incoming messages like so:

comm = new IPCommunicator("", 9000);

function OnMessageReceived(message) {
   // Handle message

Now, the parameter passed to OnMessageReceived by the IPCommunicator class will be of a .NET String type. Inside the handler function I wish to be able to write code like:

if(message == 'some command') {

But of course .NET Strings and javascript strings can't be compared like that.

Javascript's String is the exact same one as string used in c# (Both are System.String)

Your snippet code was wrong is all, change it to this:

if(message == "some command") {

and it should work fine.

All of .NET's string functions are usable with Javascript