PC Review


Reply
Thread Tools Rate Thread

Assign char range/set to array?

 
 
John E.
Guest
Posts: n/a
 
      7th Jan 2005
I cannot seem to find the equivilant of assigning a range to an array in c#.
In other languages you can do something like:

@myArray = ("a" .. "z");

or something to that effect. Thus creating an array with 26 indexes from
'a' through 'z'. How is this possible in C#? I *really* don't want to have
to type in all the characters independently for each of my different
character validators.

Any assistance is greatly appreciated.

TIA
-John



 
Reply With Quote
 
 
 
 
justin
Guest
Posts: n/a
 
      7th Jan 2005
There is no built in method for this initialization. But you could create
your own char[] creator function like:

char[] CharRange(char start, char end)
{
int size = (end - start) + 1;
char[] chars = new char[size];
for (int i = 0 ; i < size ; i++)
chars[i] = (char)(start + i);
return chars;
}

Then just call:
char[] chars = CharRange('a', 'z');

Another alternative is something like:
char[] chars = "abcdefghijklmnopqrstuvwxyz".ToCharArray();


justin.///

"John E." <PleaseReply@usenet> wrote in message
news:(E-Mail Removed)...
>I cannot seem to find the equivilant of assigning a range to an array in
>c#.
> In other languages you can do something like:
>
> @myArray = ("a" .. "z");
>
> or something to that effect. Thus creating an array with 26 indexes from
> 'a' through 'z'. How is this possible in C#? I *really* don't want to
> have
> to type in all the characters independently for each of my different
> character validators.
>
> Any assistance is greatly appreciated.
>
> TIA
> -John
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to assign range to Double array? Joe User Microsoft Excel Programming 0 23rd Nov 2009 06:45 PM
Assign Range passed to fuction to an array Michael Microsoft Excel Programming 4 3rd Mar 2009 07:52 PM
Assign a 2D array of constant values to a range dodgo Microsoft Excel Programming 4 19th Oct 2006 04:46 AM
Excel 2003. Assign array to range Jorge Vinuales Microsoft Excel Programming 2 2nd May 2006 06:06 PM
Assign Range to Array then use JOIN function Loomah Microsoft Excel Programming 5 19th Mar 2004 02:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 PM.