473,403 Members | 2,222 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,403 software developers and data experts.

More VB.NET to C# porting woes: GetType

I'm porting some VB.NET code to C# at the moment and I'm struggling with one statement:

Expand|Select|Wrap|Line Numbers
  1. Public Overrides ReadOnly Property DisplayName() As String
  2. Get
  3.   Dim mna As DisplayNameAttribute = _PropDesc.Attributes(GetType(DisplayNameAttribute))
  4.                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5.   If Not IsNothing(mna) Then
  6.     Return mna.ToString()
  7.   End If
  8.   Return _PropDesc.Name
  9. End Get
  10. End Property
  11.  
Have you any idea what this is supposed to be? GetType() is confusing me - I have only seen it as a method on an object. Here it looks to be used like a function ??

_PropDesc is a PropertyDescriptor and the Attributes member is an AttributesCollection. I'm assuming that the round brackets after the 'Attributes' is really indexing the collection/array ???

Any ideas?
Jul 19 '07 #1
2 1091
OK folks, I figured it out:

Expand|Select|Wrap|Line Numbers
  1.     public override String DisplayName 
  2.     {
  3.       get 
  4.       { 
  5.         DisplayNameAttribute mna = (DisplayNameAttribute) _PropDesc.Attributes[ typeof( DisplayNameAttribute ) ];
  6.  
  7.         if( mna != null )
  8.           return mna.ToString();
  9.  
  10.         return _PropDesc.Name;
  11.       }
  12.     }
  13.  
Jul 19 '07 #2
kenobewan
4,871 Expert 4TB
Well done, thanks for sharing the solution :).
Jul 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ryan Liu | last post by:
Hi All, Now I am porting CC to GCC and I have some problems. Would you mind tell me some document which have some description how to port CC to GCC ?? Thank you very much. Ryan
4
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light,...
0
by: John Hopper | last post by:
I use an xsd and the xsd Object Generator tool from codeProject to generate a serializable "report" class in my web service. One particular element in the xsd, from which a public property is...
0
by: Eric Hoch | last post by:
Hello, I'm writing a TypeConverter for a class which inherits arraylist, but deserializing it always results in an arraylist, which causes an InvalidCastException. If anyone can point out what...
0
by: Udi | last post by:
Hi, I have a function that I need to call in reflection that has an out parameter. The following code works fine on VS2003, but not on 2005. (I'm not receiving the out values) Good on 2003,...
1
by: Udi | last post by:
Hi All, I have a function that I need to call on reflection that has an out parameter (maybe more than one). My problem is that I'm not receiving the out values. The following code works fine...
7
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}"...
2
by: TCook | last post by:
Hey All, I'm trying to add a resource file to my app but it's not working. I have done the following: -- Added a .resx file -- Added some strings -- Named the file "MyStrings.en.resx" --...
9
by: Mark Rae | last post by:
Hi, This time, I'm looking for a regular expression which says "the string must contain exactly seven or exactly eight digits" e.g. 123456 fails 1234567 passes 12345678 passes 123456789...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.