User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 397,881 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 2,696 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: 2997 | Replies: 12
Reply
Join Date: Dec 2005
Posts: 46
Reputation: _r0ckbaer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 7
_r0ckbaer's Avatar
_r0ckbaer _r0ckbaer is offline Offline
Light Poster

Re: Dimensioning Strings

  #11  
Dec 22nd, 2005
Hi, i think you are definitely overcomplicating stuff here:
why don't you write sth like this in the ctor:
_field1 = new string(' ', 20);
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Dimensioning Strings

  #12  
Dec 22nd, 2005
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.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Dimensioning Strings

  #13  
Jan 5th, 2006
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C# Marketplace
Thread Tools Display Modes

Other Threads in the C# Forum

All times are GMT -4. The time now is 9:37 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC