Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:25:26+00:00 2026-05-23T02:25:26+00:00

I am porting a Delphi application to C#. In one of the units there

  • 0

I am porting a Delphi application to C#. In one of the units there is a declaration like this:

const
  IdentChars = ['a'..'z', 'A'..'Z', '_'];

I did not found similar declaration syntax for C#.

This is the best I could come up with:

char[] identFirstChars; // = ['a'..'z', 'A'..'Z', '_'];
int size = (int)'z' - (int)'a' + 1 + (int)'Z' - (int)'A' + 1 + 1; 
identFirstChars = new char[size];
int index = 0;
for(char ch = 'a'; ch <= 'z'; ch = (char)((int)(ch) + 1))
{
    identFirstChars[index] = ch;
    index++;
}
for (char ch = 'A'; ch <= 'Z'; ch = (char)((int)(ch) + 1))
{
    identFirstChars[index] = ch;
    index++;
}
identFirstChars[index] = '_';

There must be a more efficient way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:25:27+00:00Added an answer on May 23, 2026 at 2:25 am

    What about this?

    char[] identFirstChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_".ToCharArray();
    

    Of course, you can generate an array in your code (this probably can be done with much less lines using Enumerable.Range) but I think in your case it doesn’t worth it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am porting a Delphi application to FPC/Lazarus and this application shows info in
I am porting a Delphi application to C# and I've run into a problem.
Possible Duplicate: Porting a C array declaration to Delphi I'm converting a C code
I'm looking at porting an Interbase 6 / Delphi 7 application to embedded Firebird
While porting data from one mysql database to another there have come some issues
I'm porting some Delphi code to C#. I can't find a similar function to
I'm currently working on porting an existing Delphi 5 application to Delphi 2010. It's
I'm porting an isapi (pageproducers) application from delphi 7 to delphi 2009, the pages
Porting a pure Flash/AS3 application to Flex 4.5 this code: <fx:Script> <![CDATA[ import mx.events.SliderEvent;
I'm porting an old project to Delphi XE and I receive this warning on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.