locked
can i recive a C# Class in JavaScript?

    Question

  • i create a C# Component and create a Class named Book:

    public sealed class Book
        {
            string title = "title";
            string index = "index";
            int page = 100;
        }

    and create a method:

    public sealed class Example
        {
            public static Book GetAnswer()
            {
                Book b = new Book();
                return b;
            }

    }

    in js:

    var book = SampleComponent.Example.getAnswer();

    but i can't get the instance of Book class. how can i get the data?

    Monday, May 7, 2012 8:52 AM

Answers

  • define the class like this

     public sealed class Book
        {
            public string title { get; set; }
            public string index { get; set; }

        }

    Monday, May 7, 2012 9:25 AM

All replies

  • define the class like this

     public sealed class Book
        {
            public string title { get; set; }
            public string index { get; set; }

        }

    Monday, May 7, 2012 9:25 AM
  • Hi,

    I'm glad to hear that you resolve this issue.
    Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.

    If you have any difficulty in future programming, we welcome you to post in forums again.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Tuesday, May 8, 2012 7:05 AM
    Moderator
  • Could you please add a SampleComponent reference to js project and have a try again?
    Tuesday, May 8, 2012 7:06 AM