D
donn
I can't stop myself from using 15 minutes of my work time to express my
gratitude to Matz and everyone else involved with the creation,
enhancement, and use of Ruby. This comes from a 20 yr procedural
programmer raised on Basic, Assembler, Cobol, SAS, etc... I've been
learning Ruby for the past year, singing its praises to all around me.
And my employer, having such value of my opinion, has decided to
encourage me to learn C#, as it is the standard (from his point of
view.)
C#, in my opinion, is garbage trying to smell sweet. Especially in the
area of arrays. And here is where I solicit from you your best C#
practice to emulate Ruby. It's a simple matter of how big an array is.
In Ruby, I elegantly add member to an array using "a << 'something'."
It knows how many elements there are simply by adding. When I want to
use the elements, I elegantly code "a.each{|x| whatever}".
Now, in C#, I have to declare the array of a specific type. I have to
provide a size, x. I then have to brute force assign an element to a
specific index. And if I want to use the elements of the array, I use
a foreach statement. And because it is a statement, I have to declare
the type of receiving variable because foreach doesn't know the type of
array. And when foreach executes, it is for every element up to x, not
the number of populated elements.
Is there and elegant way in C# to append members into an array, and
execute foreach for each populated member? Or do I have to code my own
extensions to class array such that it acts like Ruby? Has someone
already done this in C#?
Once again, I can't express my appreciation enough. I'm thinking of
learning C# for my company, but still implement everything in Ruby
anyway. Hell, I can prototype production ready code in Ruby so much
faster than I can translate it to C#.
Thanks a bunch,
dvn
dvn
gratitude to Matz and everyone else involved with the creation,
enhancement, and use of Ruby. This comes from a 20 yr procedural
programmer raised on Basic, Assembler, Cobol, SAS, etc... I've been
learning Ruby for the past year, singing its praises to all around me.
And my employer, having such value of my opinion, has decided to
encourage me to learn C#, as it is the standard (from his point of
view.)
C#, in my opinion, is garbage trying to smell sweet. Especially in the
area of arrays. And here is where I solicit from you your best C#
practice to emulate Ruby. It's a simple matter of how big an array is.
In Ruby, I elegantly add member to an array using "a << 'something'."
It knows how many elements there are simply by adding. When I want to
use the elements, I elegantly code "a.each{|x| whatever}".
Now, in C#, I have to declare the array of a specific type. I have to
provide a size, x. I then have to brute force assign an element to a
specific index. And if I want to use the elements of the array, I use
a foreach statement. And because it is a statement, I have to declare
the type of receiving variable because foreach doesn't know the type of
array. And when foreach executes, it is for every element up to x, not
the number of populated elements.
Is there and elegant way in C# to append members into an array, and
execute foreach for each populated member? Or do I have to code my own
extensions to class array such that it acts like Ruby? Has someone
already done this in C#?
Once again, I can't express my appreciation enough. I'm thinking of
learning C# for my company, but still implement everything in Ruby
anyway. Hell, I can prototype production ready code in Ruby so much
faster than I can translate it to C#.
Thanks a bunch,
dvn
dvn