Metro style app: framwork and winrt (2)

Source: Internet
Author: User

In the previous article, we briefly introduced the interaction between the framework and winrt, which is much more powerful than that. We can implement cross-language calls, and this call is very simple.

For example, we have written some class libraries in C # And then we can use js to call our writing method.

Create a new class library project

 

    public sealed class WinRT    {                 public int Test(int a, int b)        {            return a + b;        }    }
Select winmd for the output type (for the winrt type, the framework is DLL), and then compile
  

We can reference this winrttest. winmd in a JS Orc ++ project.

Here, JS is used as an example. VS can only be sensed and prompt us, which is very powerful.

Of course, these are also limited.

  1. The API signature only uses the Windows runtime type.
  2. Struct can only have public data fields
  3. Only inheritance is allowed for the XAML control. The sealed keyword must be used for other types.
  4. Only built-in generics are supported.

For details, see:

Winrt APIs that can be called by C # and Visual Basic

Using the Windows runtime from C # and Visual Basic

I 'd like to talk about it much better here (I 'd like to thank boolan for its hard-working translation)

 

Although there are no more detailed documents, it is not difficult to find out through decompilation.

When we select to generate the winmd type, the compiler not only generates the class we wrote, but also generates a corresponding interface

 

Here, I guess this interface is used to intelligently prompt the compiler.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.