gettype is not working for interface

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nibin
    New Member
    • Dec 2008
    • 1

    gettype is not working for interface

    pls help me it urgent

    i m facing a problem with my vb.net code
    this is the code equivalent in c#
    this is the interface...... ..
    ............... ............... ............... ............... ............... ............... ............... ......
    namespace x
    {.
    public interface ISection
    {
    string UserControl
    {
    get;
    }

    string SectionId
    {
    get;
    }

    bool Delete();

    void SaveData();

    List<SearchResu lt> Search(string searchString, WebPage page);
    }
    ............... ............... ............... ............... ............... ............... ............... .......
    and in a another class file i use this interface isection like this
    namespace x
    {
    public class Sidebar
    ............... ............... .....
    ...............
    public static bool GetSectionRss(X mlWriter rss, ISection section, string pageId, string TitlePrefix)
    {
    if (section != null)
    {
    ChannelData SectionChannel = ((ISidebarObjec t)section).GetS idebarRss(pageI d);

    string TypeName = section.GetType ().ToString();
    ............... ............... ............... ............... ...
    ............... ............... ..............
    }}}


    it is working in C#
    but when i chane the code into vb.net
    i m getting a error message in


    dim TypeName as string =section.[gettype]().Tostring()


    i tried to use dim TypeName as string =section.gettyp e()

    but i cannot type like .......
    later i know that type of a interface cannot getthrough GetType()

    but i want to get the type of that interface...... ..........
    pls help me ,tell me another method for it.

    thanks in advance........ .............
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    Post your VB.NET code so we can check it out...

    Steven

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      There's a GetType method in VB.NET that retrieves a Type Object containing information for an Object/Structure. Once you have the Type object you can retrieve the name, properties, methods...etc etc

      The following example demonstrates how to retrieve the Name:
      [code=vbnet]
      Dim theType as Type = GetType(section )
      Dim theName as String = theType.Name[/code]

      Comment

      Working...