Application experience of vb.net generic type

Source: Internet
Author: User

Vb. NET programming language has a wide variety of data types, it is a difficult step for beginners to master all these types of applications. Today, let's get to know the application of the higher-order technology of the vb.net generic type, so that we can understand the language in depth.

When you define a vb.net generic type, it is parameterized even with one or more data types. This allows you to customize the data type with code to meet its requirements. The code can declare several different programming elements through a generic element, each of which can use a different set of data types. However, regardless of which data types are used by the declared element, they perform the same logic.

Base class definition

Namespace result public    MustInherit Class result public        Sub New ()        End Sub Property        msg as String        Property success as Boolean    End classend Namespace

  

To define a function implementation:

    Shared Function Resultt (Of T as Models.result.result) (msg as String) as T        Dim rsp As T = Nothing        Dim parser as Mod Els.result.result = Nothing        rsp.msg = msg        rsp.success = False        return RSP        ' return New API. Resultobj (of T) with {. msg = msg,. Success = False}    End Function

  

Invocation Example:

Return RESULTT (of Models.result.httputil) (msg)

  

Application experience of vb.net generic type

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.