•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,711 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,408 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 2971 | Replies: 12
![]() |
Hi, i think you are definitely overcomplicating stuff here:
why don't you write sth like this in the ctor:
why don't you write sth like this in the ctor:
_field1 = new string(' ', 20); Doh!
For some reason I had convinced myself that I'd need to use Reflection... because I'd have to set only those properties that represent fields to space-filled strings, but not any other public properties. Somehow "Reflection" popped into my head, and prevented me from seeing the obvious: only set the properties you actually need to set...
I'm still using the Dictionary, so that the field lengths are only coded in one spot. The Contructor and the Public "setter" proc can both reference the Dictionary.
Thanks for your help.
For some reason I had convinced myself that I'd need to use Reflection... because I'd have to set only those properties that represent fields to space-filled strings, but not any other public properties. Somehow "Reflection" popped into my head, and prevented me from seeing the obvious: only set the properties you actually need to set...
I'm still using the Dictionary, so that the field lengths are only coded in one spot. The Contructor and the Public "setter" proc can both reference the Dictionary.
Thanks for your help.
Just so this thread doesn't make me look like a complete dope...
The class will be used in another application. That application parses a configuration file. That config file contains the name of the property to set, followed by an expression telling it how to find the value.
So, I had to use reflection anyway to turn the name of the field, from the config file, into the actual property to set. I just didn't need to use reflection in the class itself.
The class will be used in another application. That application parses a configuration file. That config file contains the name of the property to set, followed by an expression telling it how to find the value.
So, I had to use reflection anyway to turn the name of the field, from the config file, into the actual property to set. I just didn't need to use reflection in the class itself.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
Other Threads in the C# Forum
- Previous Thread: delegates
- Next Thread: Looking for Good C# book.



Linear Mode