Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
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
 
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 :(

 
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
 
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

 
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


 
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++)






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.