473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

System.Type

Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to determine
the on what interface does the class implement. Any idea anyone?

thanks in advance.


Type[] types = myAssembly.GetTypes();
foreach(Type t in types)
{
if (t.IsSubclassOf(typeof(InternetNow.IInowForm)))
{
....
}

}
Nov 16 '05 #1
5 1693
On Sat, 15 Jan 2005 10:51:42 +0800, Semut wrote:
Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to determine
the on what interface does the class implement. Any idea anyone?

thanks in advance.

Type[] types = myAssembly.GetTypes();
foreach(Type t in types)
{

if (t.IsSubclassOf(typeof(InternetNow.IInowForm)))
{
...
}

}


if (t as InternetNow.IInowForm != null)
{
...
}

or

if(t.GetInterface("InternetNow.IInowForm") != null)
{
...
}
--
Tom Porterfield
Nov 16 '05 #2
Semut wrote:
Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to determine
the on what interface does the class implement. Any idea anyone?


System.Type.FindInterfaces

--

www.midnightbeach.com
Nov 16 '05 #3
A bit overkill for my purpose but it seems like a possible way.

thanks

"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:41***************@midnightbeach.com...
Semut wrote:
Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to
determine
the on what interface does the class implement. Any idea anyone?


System.Type.FindInterfaces

--

www.midnightbeach.com

Nov 16 '05 #4
The first one not working but the second method does.

thanks

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:7c**************@tpportermvps.org...
On Sat, 15 Jan 2005 10:51:42 +0800, Semut wrote:
Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to
determine
the on what interface does the class implement. Any idea anyone?

thanks in advance.

Type[] types = myAssembly.GetTypes();
foreach(Type t in types)
{

if (t.IsSubclassOf(typeof(InternetNow.IInowForm)))
{
...
}

}


if (t as InternetNow.IInowForm != null)
{
...
}

or

if(t.GetInterface("InternetNow.IInowForm") != null)
{
...
}
--
Tom Porterfield

Nov 16 '05 #5
Semut,
In addition to the other comments:

You might be able to use Type.IsAssignableFrom in both cases.

Something like:
if (typeof(InternetNow.IInowForm).IsAssignableFrom(t) )
{
...
}

Hope this helps
Jay

"Semut" <an*****@hotmail.com> wrote in message
news:Ot****************@TK2MSFTNGP14.phx.gbl... Hello, below is a code snippet on determine what class does the class
inherit from. This is working fine until I need a requirement to determine
the on what interface does the class implement. Any idea anyone?

thanks in advance.


Type[] types = myAssembly.GetTypes();
foreach(Type t in types)
{
if (t.IsSubclassOf(typeof(InternetNow.IInowForm)))
{
...
}

}

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. ...
4
by: Stofdeel | last post by:
Heya, I am looking for information about the System.RuntimeType and other Runtime classes. They are undocumented in my version of Visual Studio. So far I have no luck with internet, only some...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
0
by: nicomp | last post by:
I created a Web Service: I imported System.Data.SqlClient so I could access SQL server tables programmatically. The web service builds and deploys with no problems. When I try to add the...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.