- Home /
Question by
JellyDoodle · Jun 12, 2015 at 07:13 PM ·
c#javascriptvariableclasstypecasting
How to Typecast JS Variables as C# Classes?
If I want to typecast a variable in js as defined in cs. How do I do that?
For example:
C# Code
namespace SocketIO
{
public class SocketIOEvent
{
public string name { get; set; }
public JSONObject data { get; set; }
public SocketIOEvent(string name) : this(name, null) { }
public SocketIOEvent(string name, JSONObject data)
{
this.name = name;
this.data = data;
}
public override string ToString()
{
return string.Format("[SocketIOEvent: name={0}, data={1}]", name, data);
}
}
}
JS Code
// custom callback function which is passed a SocketIOEvent object
function OnMessageReceived (event: SocketIOEvent) {
}
How do I correctly typecast event on the OnMessageReceived function?
I am (unsurprisingly) receiving the error: The name 'SocketIOEvent' does not denote a valid type ('not found').
Comment