473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Assign char range/set to array?

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

Nov 16 '05 #1
1 3046
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:ed*************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: wallacej | last post by:
Does anybody know why unsigned char myImage; works but unsigned char myImage; does not? I think its because the second line is a value too big for unsigned char, is this ...
2
by: Peter Nilsson | last post by:
In a post regarding toupper(), Richard Heathfield once asked me to think about what the conversion of a char to unsigned char would mean, and whether it was sensible to actually do so. And pete has...
4
by: ravinderthakur | last post by:
hi all experts, can anybody explain me the difference between the unsigned char and char in c/c++ langugage. specifically how does this affects the c library fucntion such as strcat,strtok...
51
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
2
by: radishcarrot | last post by:
unsigned char *m_pVolumeData; m_pVolumeData = new unsigned char; FILE *fp = fopen(filename, "rb"); if(fp) { fread(m_pVolumeData, 1, m_nSizeX * m_nSizeY * m_nSizeZ, fp); fclose(fp); } ...
2
by: rachit.goyal | last post by:
Hi All, I am using .net first time.In my windows form VC7 application, on a click of button, I am assigning text of TextBox to STL string varibale. Using this code- private: System::Void...
3
by: roopa.v1 | last post by:
Hi, How to assign long to character array and later extract it
7
by: dtschoepe | last post by:
Hi, I am working on a project for school and I am trying to get my head around something weird. I have a function setup which is used to get an input from stdin and a piece of memory is created...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.