473,387 Members | 1,790 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,387 software developers and data experts.

String constant array?

Hello all,

I am new guy on C#. So, my question will be very simple to you guys here.
I want to use string constants array from C# like C++ like below.

in C++ :

char const * const attr_strings[] = {
"NORMAL",
"EDGE",
"SHADOW",
"UNDERLINE"
};

And, use it later like below :

cout << attr_strings[_attr] << endl;

How can I define above C++ like string constant arrays in C#?

Thanks.
Nov 15 '05 #1
1 17513
Hi,
I'm quite new to C# too but I think its something like this:

readonly string[] attr_strings = new string[]{"NORMAL", "EDGE", "SHADOW",
"UNDERLINE"};

hth,
Nick

"wonil kim" <wo*******@nospam.hotmail.com> schrieb im Newsbeitrag
news:uy**************@TK2MSFTNGP10.phx.gbl...
Hello all,

I am new guy on C#. So, my question will be very simple to you guys here.
I want to use string constants array from C# like C++ like below.

in C++ :

char const * const attr_strings[] = {
"NORMAL",
"EDGE",
"SHADOW",
"UNDERLINE"
};

And, use it later like below :

cout << attr_strings[_attr] << endl;

How can I define above C++ like string constant arrays in C#?

Thanks.

Nov 15 '05 #2

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

Similar topics

8
by: Jason Heyes | last post by:
If s is a std::string, does &s refer to the contiguous block of characters representing s?
7
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have...
4
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
3
by: Francois | last post by:
Hi, In c#, is it possible to have an array of string declared as being constant: something like: protected const string OptionsGameFilterValues = new String {"Tom", "Jon", "Henry"}; but...
5
by: cdg | last post by:
Could anyone explain how to write this sample program correctly. I need to convert an integer to a string. However, I would prefer to convert the integer to char array. But I didn`t want to use...
14
by: nospam | last post by:
From the book "There is an important difference between these definitions: char amessage="now is the time"; char *pmessage ="now is the time"; snip On the other hand, pmessage is a...
18
by: sinbad | last post by:
hi, why does the following program gives an runtime error ,instead of compilation error. anyone please shed some light. thanks sinbad ------------------------------ int main()
13
by: sinbad | last post by:
hi, how to concatenate a "hash defined" constant value to another "hash defined" constant string. For example #define ABC 100 #define MYSTR "The value of ABC is" Now i need a string that...
7
by: Hendrik Schober | last post by:
Hi, this #include <string> class test { typedef std::string::size_type size_type; static const size_type x = std::string::npos; }; doesn't compile using either VC9 ("expected constant...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.