I am new to Windows 8 development, my question is: how do I use C# Singleton in Javascript app? I am using the Static Initialization ( http://msdn.microsoft.com/en-us/library/ff650316.aspx ) in my C# class. MyClass.Instance (which returns the singleton instance) is undefined when I call it in Javascript. Thanks.
EDIT: I have a C# class which is Singleton, and I am trying to use it with my Javascript Windows 8 App, I am not trying to implement Singleton in Javascript.
Language projection will slightly change the name of properties to conform to the patterns used in the consuming language. So when you define a property MyClass::Instance
in C#, you should have MyClass.instance
(lowercase 'i') in JavaScript.
Also, you can browse the available functions and properties in the JavaScript debugger (using Shift+F9 and entering "MyClass" for example is one way).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.