Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 23rd, 2003, 08:51 AM
Authorized User
Join Date: Jul 2003
Location: , , .
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable Differences

Hello Everyone and thanks for your help in advance. I am working on a file browser from an ASP.Net page. When I come across examples of recursing through the files in a directory, most of the examples have something like:

Dim Files() As String
Files = Directory.GetFiles(myDirectory)

My question is, what is the difference between:

Dim Files As String and Dim Files() As String

It appears that Files() is some sort of array, but I am not clear on this. Any insight on this owuld be greatly appreciated. Thanks.

  #2 (permalink)  
Old December 30th, 2003, 12:16 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Well, you can declare an array of any object. Despite it's name, "Files" is a single string whereas "Files()" is an array of strings. Simply put, you should be able to give any variable the trailing () and create an array of them.

Here's the thing that will really twist your noodle:

What's the difference between

    Dim Files() As String
    Dim Files As String()

They do the same thing but I've always wondered if there is a difference. Perhaps it's just a flexibility in VB of where you can specify the variable as an array. It's frankly a poor "feature" because using the "String()" kind of implies a constructor. When used in this case, it certainly isn't one.

Work smarter, not harder.

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML differences mrame XSLT 4 October 6th, 2008 07:34 AM
mozilla/IE 7 differences Adam H-W CSS Cascading Style Sheets 2 July 9th, 2007 04:16 AM
Code differences afharris_83 BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 5 May 8th, 2007 10:14 AM
Xcode 2.4 differences craigontour Xcode 1 November 24th, 2006 11:08 PM
objDataAdapter Differences cpbittner BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 September 20th, 2004 08:09 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.