473,813 Members | 3,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array of String Constants?

I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!
Jun 27 '08 #1
3 1724
Joe Cool wrote:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }
private string[] DataTypes = { "Text", "Integer", "Date" };

Arne

PS: There are tools (also web based) that can convert between
C# and VB.NET !
Jun 27 '08 #2
Joe Cool wrote:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!
If you want your string would be constant, add readonly keyword
private readonly string[] DataTypes = new string[] { "Text", "Integer",
"Date" };
--
Thanks,
Duy Lam Phuong
Jun 27 '08 #3
Duy Lam <du**********@g mail.comwrote:
Joe Cool wrote:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!

If you want your string would be constant, add readonly keyword
private readonly string[] DataTypes = new string[] { "Text", "Integer",
"Date" };
Unfortunately that doesn't stop the array contents from being changes.
It prevents code like this:

DataTypes = new string[5];

but it doesn't stop:

DataTypes[0] = "Image";

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #4

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

Similar topics

7
5153
by: richbl | last post by:
Hello all, I have a question about unserializing a single array element from a serialized array. Can this be done, or must I first unserialize the array, and then access the element? For example, given: $data = serialize(array('4.50','0.00','0.00'));
2
5355
by: Paul | last post by:
Please help, I am working on an Active-x project involving Arrays with up to 20 elements populated in a class module. In order to keep programming and debugging simple, Instead of refering to each element with numbers, would it be correct to refer to each element with constants as per the example shown bellow. Option Explicit Dim AddrArray(1 To 20, 1 To 3) Dim Address As clsMyClass
2
2250
by: SunMan | last post by:
Hello! I am trying to create a program that will ask for a user to enter a series of letters (codes) and then print out a table that shows the codes in decending frequency. Only letters will be read into the array. I have created a struct and array like below. struct record { char inputChar;
4
2146
by: JR | last post by:
Hey all, I am passing a two dimensional array to a function. It basically looks like this int test(double array2 , const CONST1, const CONST2) { int returnValue; for (int i = 0; i<=CONST1; ++i) {
3
2225
by: ESPNSTI | last post by:
Hi, I'm looking for a way to associate multiple "lists" of constants to each other. For example, I'd like a way to look up a database column's name based on its "number" in a constants list. I'm new to C# and my background is in Delphi, so below is an example of how I would declare such a constant array of records in Delphi. ______________________________________________________
8
6916
by: Ben R. | last post by:
Hi there, Could anyone let me know what the c's are for in this statement: Private Shared hexDigits As Char() = {"0"c, "1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "A"c, "B"c, "C"c, "D"c, "E"c, "F"c} Thanks!
2
2331
by: comp.lang.php | last post by:
var $filterArray = array('reverse' =IMG_FILTER_NEGATE, 'edge highlight' =IMG_FILTER_EDGEDETECT, 'emboss' =IMG_FILTER_EMBOSS, 'gaussian blur' =IMG_FILTER_GAUSSIAN_BLUR, 'blur' =IMG_FILTER_SELECTIVE_BLUR, 'sketchy' =IMG_FILTER_MEAN_REMOVAL); I am trying to generate an HTML dropdown from this array, however, when
3
1608
by: Morten71 | last post by:
I have a strange problem. I have a local string() var I populate this way: clmns() As String = {"InvoiceNo", "InvoiceDate"} When I call: Array.IndexOf(clmns,"InvoiceDate") I get 0 (zero) as expected. If I fetch the values from the web.config this way: clmns() As String =
8
1318
by: fauxanadu | last post by:
Hello: I've been working on an assignment and I have hit a stumbling block pertaining to an array of pointers. If I am correct in my assumptions, the array struct animal* zoo should have its address passed to a function when calling it like this: somefunc(zoo);
24
2947
by: arnuld | last post by:
I want to create a new array of the same size of an array already available: #include <stdio.h> #include <string.h> int main(void) { char arrc = "URI";
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10422
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3885
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.