471,348 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

ListViewItem and ListViewSubItem

Hi,

I have some problem. I try to get ListViewSubItem type using:

Type t = (new
Form).GetType().Assembly.GetType("System.Windows.F orms.ListViewItem.ListViewSubItem")

but I get t == null. I notice that I can do that using:

Type t = (new
Form).GetType().Assembly.GetType("System.Windows.F orms.ListViewItem
+ListViewSubItem")

Why I have to use "+" sign in namespace? What does it mean? Whay in
msdn is ListViewItem.ListViewSubItem not ListViewItem+ListViewSubItem?

Best regards,
Klaudiusz
Aug 1 '08 #1
3 3682
On Fri, 01 Aug 2008 05:07:30 -0700, Klaudiusz Bryja
<br*************@poczta.fmwrote:
I have some problem. I try to get ListViewSubItem type using:

Type t = (new
Form).GetType().Assembly.GetType("System.Windows.F orms.ListViewItem.ListViewSubItem")

but I get t == null.
What are you _really_ trying to do? That is, why do you even want the
type?

As far as your question goes, it seems to me that the most
straight-forward fix is to not use Assembly.GetType() at all. Just use
the "typeof" operator:

Type t = typeof(ListViewSubItem);

Pete
Aug 1 '08 #2
+ is the token used internally to indicate nested classes, rather than
classes within a namespace. However, there is no need to use strings here:

Type type = typeof(System.Windows.Forms.ListViewItem.ListViewS ubItem);

Marc
Aug 1 '08 #3
On Aug 1, 4:07*pm, Klaudiusz Bryja <bryja_klaudi...@poczta.fmwrote:
Why I have to use "+" sign in namespace? What does it mean? Whay in
msdn is ListViewItem.ListViewSubItem not ListViewItem+ListViewSubItem?
"+" is a reflection-specific way of denoting nested classes. In C# you
can use "." because the compiler handles this for you; however, this
means that in C#, you cannot have a namespace that contains another
namespace and a class with the same name (CLS forbids this as well, by
the way). CLR itself does not restrict such a thing, however, so you
can write it in IL and compile using ilasm, for example, and
reflection should be able to handle any valid CLR assembly, whether it
is generated by C# or something else, and whether it is CLS-compliant
or not, so it had to make this explicit.
Aug 1 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by grs | last post: by
reply views Thread by Kluch | last post: by
1 post views Thread by Laurence Bunnage | last post: by
1 post views Thread by Alan T | last post: by
reply views Thread by garyusenet | last post: by
10 posts views Thread by Gav | last post: by
reply views Thread by Ronak mishra | last post: by

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.