Hi,
Is it possible on VB.NET to create anonymous arrays, e.g. passing
arrays directly as a method-parameter instead of reference it from a
variable.
In C#, I can do this:
string s = "Blah blah, Aloha!";
string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way?
Dim s As String = "Blah blah, Aloha!"
Dim seperator() As Char = {CType(",", Char)}
Dim sArr() As String = s.Split(seperator) 6 7447
Hi,
Not really sure what u r asking.. but.. in VB y not code as follows?
Dim s As String = "Blah blah, Aloha!"
Dim sArr() As String = s.Split(CChar(","))
not sure how this is all that different from the C# version? appart from the
syntax obv.
Rigga.
"Anders Thomsen" <ju**@mexp.dk> wrote in message
news:5d**************************@posting.google.c om... Hi,
Is it possible on VB.NET to create anonymous arrays, e.g. passing arrays directly as a method-parameter instead of reference it from a variable.
In C#, I can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way? Dim s As String = "Blah blah, Aloha!" Dim seperator() As Char = {CType(",", Char)} Dim sArr() As String = s.Split(seperator)
Hi Anders, In C#, I can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way? Dim s As String = "Blah blah, Aloha!" Dim seperator() As Char = {CType(",", Char)} Dim sArr() As String = s.Split(seperator)
Most people do it like this,
Dim s As String = "Blah blah, Aloha!"
Dim sArr() As String = s.Split(",")
Maybe this is better, but I did never saw it done in this newsgroup and I
did not look to the intermidiate code for this.
Dim s As String = "Blah blah, Aloha!"
Dim sArr() As String = s.Split(","c)
I hope this helps?
Cor
"Anders Thomsen" <ju**@mexp.dk> schrieb Is it possible on VB.NET to create anonymous arrays, e.g. passing arrays directly as a method-parameter instead of reference it from a variable.
In C#, I can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way? Dim s As String = "Blah blah, Aloha!" Dim seperator() As Char = {CType(",", Char)} Dim sArr() As String = s.Split(seperator)
Dim sArr() As String = s.Split(new char(){","c})
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Dim s As String = "Blah blah, Aloha!"
Dim sArr() As String = s.Split(New Char() {","c})
--
HTH,
-- Tom Spink, Über Geek
Woe be the day VBC.EXE says, "OrElse what?"
Please respond to the newsgroup,
so all can benefit
"Anders Thomsen" <ju**@mexp.dk> wrote in message
news:5d**************************@posting.google.c om... Hi,
Is it possible on VB.NET to create anonymous arrays, e.g. passing arrays directly as a method-parameter instead of reference it from a variable.
In C#, I can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way? Dim s As String = "Blah blah, Aloha!" Dim seperator() As Char = {CType(",", Char)} Dim sArr() As String = s.Split(seperator)
* ju**@mexp.dk (Anders Thomsen) scripsit: Is it possible on VB.NET to create anonymous arrays, e.g. passing arrays directly as a method-parameter instead of reference it from a variable.
Yes:
\\\
....(..., New Char() {","c, ":"c, ...}, ...)
///
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Anders,
In addition to the others comments (on how to actually create an "anonymous"
array) :
In C# you can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(',');
In VB, you can also do this: Dim s As String = "Blah blah, Aloha!" Dim sArr() As String = s.Split(","c)
Seeing as String.Split uses a ParamArray parameter, the compiler will
dynamically create an "anonymous" array for you, there is no real need to
explicitly create one (although one is supported if you already have one, or
you need to use String.ToCharArray).
Hope this helps
Jay
"Anders Thomsen" <ju**@mexp.dk> wrote in message
news:5d**************************@posting.google.c om... Hi,
Is it possible on VB.NET to create anonymous arrays, e.g. passing arrays directly as a method-parameter instead of reference it from a variable.
In C#, I can do this: string s = "Blah blah, Aloha!"; string[] sArr = s.Split(new String[]{","});
In VB, do I really have to do it this way? Dim s As String = "Blah blah, Aloha!" Dim seperator() As Char = {CType(",", Char)} Dim sArr() As String = s.Split(seperator) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nick Coghlan |
last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0.
Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped
in favour of a different syntax,...
|
by: ip4ram |
last post by:
I used to work with C and have a set of libraries which allocate
multi-dimensional arrays(2 and 3) with single malloc call.
data_type **myarray
=...
|
by: Stijn van Dongen |
last post by:
A question about void*. I have a hash library where the hash create
function accepts functions
unsigned (*hash)(const void *a)
int (*cmp) (const void *a, const void *b)
The insert function...
|
by: Paul E Collins |
last post by:
This does what you'd expect ...
string foo = { "bar", "baz", "quux" };
.... so why is this a syntax error?
private string foo()
{
return { "bar", "baz", "quux" };
}
|
by: yeti349 |
last post by:
Hi, I'm using the following code to retrieve data from an xml file and
populate a javascript array. The data is then displayed in html table
form. I would like to then be able to sort by each...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: John Mark Howell |
last post by:
I had a customer call about some C# code they had put together that was
handling some large arrays. The performance was rather poor. The C# code
runs in about 22 seconds and the equivalent...
|
by: jacob navia |
last post by:
Gnu C features some interesting extensions, among others
compound statements that return a value. For instance:
({ int y = foo(); int z;
if (y>0) z = y; else z=-y;
z;
})
A block enclosed by...
|
by: David Golightly |
last post by:
Quick question for the gurus out there: in ECMAScript, one can create
a new Array object with a length like so:
var animals = new Array(128);
This creates a new Array object with a "length"...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |