GetType() is not working with interace
-
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.....................
-
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.....................
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:
-
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:
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.
-
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.
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 ModuleI 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!