Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old January 18th, 2008, 10:54 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by weicco
 It is possible with reflection:

Yes, my bad. However, I highly doubt this type of solution is what reflection is intended for. That's hitting the proverbial nail with a sledgehammer.

-Peter
Reply With Quote
  #12 (permalink)  
Old January 18th, 2008, 11:21 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by joefawcett
 C# uses the declaration to specify length so new string is an array of length with elements 0 - 7.

Thank you for the correction Joe. (You'd think MS could have "normalized" that too while they were fixing all the other datatype inconsistencies.)

-Peter
Reply With Quote
  #13 (permalink)  
Old January 19th, 2008, 02:56 PM
Authorized User
 
Join Date: Sep 2007
Location: , , Finland.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 
Quote:
quote:Originally posted by weicco
Quote:
 It is possible with reflection:

Yes, my bad. However, I highly doubt this type of solution is what reflection is intended for. That's hitting the proverbial nail with a sledgehammer.

-Peter
Well a lot of (bad) ORMs work with reflection but not with fields but properties. Its a ugly thing (reflection) but can save you form writing some hundred lines of code.

And that string[SIZE] thingy. I'm old C coder and it would be absolute horror for me if indexing would start from 1 all the sudden. In C family languages indexing starts from zero! :)

I do some VB.NET projects from time to time and every fricking time when I access array using index I forget that in VB indices start from 1. It drives me nuts! IndexOutOfBounds has become very familiar exception to me :(

Reply With Quote
  #14 (permalink)  
Old January 19th, 2008, 05:34 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I meant that it would be nice if they fixed the array initialization so that VB was consistent with the other. I certainly didn't mean to suggest that array indexing should be 1 based, oh the horror.

-Peter
Reply With Quote
  #15 (permalink)  
Old January 20th, 2008, 05:32 AM
Authorized User
 
Join Date: Sep 2007
Location: , , Finland.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah. Now I got it. But still its C family language and it should act like any other language in that category, imo. (Visual) Basic on the other hand is a different kind of beast and is "the leading cause of brain damage in proto-hackers" ;)

http://www.catb.org/~esr/jargon/html/B/BASIC.html

Reply With Quote
  #16 (permalink)  
Old January 20th, 2008, 11:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

 
Quote:
quote:It is possible with reflection:
Quote:

class Foo {
    string p1, p2, ..., p9;
}
...if the fields are public and begin with p0:

class Foo {
    public string p0, p1, p2, ..., p9;
}

- Bob


Reply With Quote
  #17 (permalink)  
Old January 20th, 2008, 12:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

...or change

Code:
for (int i = 0; i < 10; i++)
to...
Code:
for (int i = 1; i < 10; i++)


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting onChange Event w/Dynamically Created Form rvanandel Javascript How-To 4 June 28th, 2007 08:10 AM
Setting Gridview Dynamically copelanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 February 21st, 2007 01:28 PM
Dynamically Setting X, Y Coordiantes of Element hugh@kmcnetwork.com Javascript 4 August 21st, 2005 05:01 AM
Subform - Dynamically Setting mnoon Access 14 March 13th, 2005 07:33 PM
Setting stylesheet for dynamically created object tgopal Javascript 2 September 6th, 2004 11:47 PM



All times are GMT -4. The time now is 03:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.