473,486 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

String Array

Is there a way to declare AND in the same line assign values to a string
array?

TIA
Nov 21 '05 #1
8 4816
Dim str1(2) As String = {"1","2","3"}
"C CORDON" wrote:
Is there a way to declare AND in the same line assign values to a string
array?

TIA

Nov 21 '05 #2
"C CORDON" <tc******@hotmail.com> schrieb:
Is there a way to declare AND in the same line assign values to a string
array?


\\\
Dim s() As String = {"Bla", "Foo", "Goo"}
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
"C CORDON" <tc******@hotmail.com> schrieb:
Is there a way to declare AND in the same line assign values to a string
array?


\\\
Dim s() As String = {"Bla", "Foo", "Goo"}
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Am I the only one that does this differently (with the same result)???

Dim s As String() = New String() { "Bla", "Foo", "Goo" }

???

Maybe so :P

Mythran
Nov 21 '05 #4
"Mythran" <ki********@hotmail.comREMOVETRAIL> schrieb:
Am I the only one that does this differently (with the same result)???

Dim s As String() = New String() { "Bla", "Foo", "Goo" }


I prefer to type less characters, but the code will produce the exact same
IL.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Thank You!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uj*************@TK2MSFTNGP15.phx.gbl...
"Mythran" <ki********@hotmail.comREMOVETRAIL> schrieb:
Am I the only one that does this differently (with the same result)???

Dim s As String() = New String() { "Bla", "Foo", "Goo" }


I prefer to type less characters, but the code will produce the exact same
IL.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
Would not his code create an array of string arrays? I don't think
that is the same.

Chris

Nov 21 '05 #7
Chris,

"Chris Dunaway" <du******@gmail.com> schrieb:
Would not his code create an array of string arrays? I don't think
that is the same.


\\\
Dim astr1() As String = {"Foo", "Bar", "Baz"}
Dim astr2 As String() = {"Foo", "Bar", "Baz"}
Dim astr3() As String = New String() {"Foo", "Bar", "Baz"}
Dim astr4 As String() = New String() {"Foo", "Bar", "Baz"}
///

.... are semantically the same. All four lines will create one-dimensional
string arrays that contain three strings.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
I misread the original post. I thought he had written:

Dim s() As String() = New String() = {"Foo", "Bar", "Baz"}

which will generate a compile time error.

Nov 21 '05 #9

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

Similar topics

16
17346
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char *...
7
4341
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
5370
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...
22
17129
by: spike | last post by:
How do i reset a string? I just want to empty it som that it does not contain any characters Say it contains "hello world" at the time... I want it to contain "". Nothing that is.. Thanx
4
8773
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
14
14999
by: Bob | last post by:
I have a function that takes in a list of IDs (hundreds) as input parameter and needs to pass the data to another step as a comma delimited string. The source can easily create this list of IDs in...
8
13934
by: Jeff Johnson | last post by:
Hi, I've begun converting an ASP site over to .NET and I'm a novice at both the new platform as well as C#. I have a COM+ object that returns a string array when it is called. The size of...
17
4632
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
11
17618
by: Zordiac | last post by:
How do I dynamically populate a string array? I hope there is something obvious that I'm missing here Option Strict On dim s() as string dim sTmp as string = "test" dim i as integer ...
14
4042
by: Shhnwz.a | last post by:
Hi, I am in confusion regarding jargons. When it is technically correct to say.. String or Character Array.in c. just give me your perspectives in this issue. Thanx in Advance.
0
6967
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
7132
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,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
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...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4564
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
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 ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.