Question about the GetType method used by the interface

Source: Internet
Author: User

C # The Code is as follows:
Public interface iconfiginfo
{
}
Public Class A: iconfiginfo
{

}
Public Class B
{
Void BB (iconfiginfo)
{
Type T = A. GetType ();
}
}

The VB.net code is as follows:
Public interface iconfiginfo
End Interface
Public Class
Implements iconfiginfo

End Class
Public Class B
Private sub BB (byval A as iconfiginfo)
Dim t as type = A. GetType ()
End sub
End Class, please pay attention to the red part. Among them, the C # code runs normally, while VB does not. The error cause is: A. GetType ()Tip: GetType is not a member of iconfiginfo.

In the garden, Sha Jia said:
Convert a to an object first.
----
Dim t as type = ctype (A, object). GetType ()

---
This is the case .... Very depressed. Why can a. GetType () be used in C # To obtain the object type, but not in VB?

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.