Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. GetType() is not working with interace

GetType() is not working with interace

Scheduled Pinned Locked Moved Visual Basic
helpcsharp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nibinki333
    wrote on last edited by
    #1

    pls help me its urgent i m facing a problem with my vb.net code this is the code equivalent in c# this is a interface........ ............................................................................................................... namespace x {. public interface ISection { string UserControl { get; } string SectionId { get; } bool Delete(); void SaveData(); List Search(string searchString, WebPage page); } ................................................................................................................ and in another class file this interface 'isection' is used like this namespace x { public class Sidebar ................................... ............... public static bool GetSectionRss(XmlWriter rss, ISection section, string pageId, string TitlePrefix) { if (section != null) { ChannelData SectionChannel = ((ISidebarObject)section).GetSidebarRss(pageId); 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.gettype() but i cannot type like it 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.....................

    L 1 Reply Last reply
    0
    • N nibinki333

      pls help me its urgent i m facing a problem with my vb.net code this is the code equivalent in c# this is a interface........ ............................................................................................................... namespace x {. public interface ISection { string UserControl { get; } string SectionId { get; } bool Delete(); void SaveData(); List Search(string searchString, WebPage page); } ................................................................................................................ and in another class file this interface 'isection' is used like this namespace x { public class Sidebar ................................... ............... public static bool GetSectionRss(XmlWriter rss, ISection section, string pageId, string TitlePrefix) { if (section != null) { ChannelData SectionChannel = ((ISidebarObject)section).GetSidebarRss(pageId); 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.gettype() but i cannot type like it 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.....................

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, an Interface has a GetType() method, even in VB.NET don't let Intellisense fool you (there may be a custom/all button that hides some). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Fixturized forever. :confused:


      N 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, an Interface has a GetType() method, even in VB.NET don't let Intellisense fool you (there may be a custom/all button that hides some). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Fixturized forever. :confused:


        N Offline
        N Offline
        nibinki333
        wrote on last edited by
        #3

        thanks for ur answer but anyway if i use like this ie interface.[gettype]() it shows an error that gettype is not a member of interface.

        L 1 Reply Last reply
        0
        • N nibinki333

          thanks for ur answer but anyway if i use like this ie interface.[gettype]() it shows an error that gettype is not a member of interface.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Imports System
          Module Module1
          Interface ISomething
          Sub fDouble()
          End Interface
          Class Whatever
          Implements ISomething
          Sub fDouble() Implements ISomething.fDouble
          Console.WriteLine("whatever")
          End Sub
          End Class
          Sub Main()
          Dim some As ISomething = New Whatever
          Console.WriteLine(some.GetType().ToString())
          Console.ReadLine()
          End Sub
          End Module

          I suggest you buy an introductory book on VB.NET and study it...

          Luc Pattyn [Forum Guidelines] [My Articles]


          Love, happiness and fewer bugs for 2009!


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups