Need help understanding NEW keyword

I can create a string array a couple of different ways.
Method one:
      Dim i As Integer
      Dim sarr1(4) As String
      For i = 0 To sarr1.Length - 1
         sarr1(i) = "12345"
      Next
Method two:     
     Dim sarr2 = New String() {"12345", "12345", "12345", "12345", "12345"}
Are these two methods equivalent?
If I try to declare the arrays by either of the following methods, I get errors.
Method three:
       Dim sarr3 As New String(4)
       error: Value of type 'Integer' cannot be converted to '1-dimensional array of Char'.
Method four:
        Dim sarr4(4) As New String()
        error: Arrays cannot be declared with 'New'.
Why isn't method four equivalent to method two except for the initialization?     
Regards, Mike

Method 1 and 2 are basically the same. We didn't always have array initializers in the language (method2). That has only been around the past couple of years. Prior to that you had to do some sort of loop to initialize the array like your method 1. Method
2 was added just to make it easier from a syntax point of view. It certainly looks cleaner and you can read one line of code and know what the array is and what its contents are.
The reason method 2 and method 4 are different is because in method 2, you are performing an assignment. It is using type inference so it might not be as clear, but method 2 could be fully written out as
Dim sarr2() As String = New String() {"12345", "12345", "12345", "12345", "12345"}
In which case you can see that it isn't really using the new keyword for the declaration, but for the right side instantiation of a string array, which is then assigned to the declared array variable.
Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com

Similar Messages

  • I need help understanding how the Apple components integrate to create a system across all my devices?

    I need help understanding how the Apple components connect to create a whole system across all my devices?
    Is there a resource that describes current system and associated functionality?
    For example:
    Buy A, B, C to achieve "X" 
    You will need:
    an internet provider which supports <specs>
    add D to achieve "Y"
    You will need:
    an internet provider which supports <specs>
    add "E" to achieve "Z"
    You will need:
    an internet provider which supports <specs>
    For example, I am looking at the Gen 6 Airport extreme.  For intended performance do I need broadband? if so what are the specs, or will basic internet service suffice?  Do I need the internet provider's modem or does the Airport extreme replace that?  And then I think, if I am doing this, I should also look at Apple TV....What do I need and Why?  Then I look at the New Desk top coming out in the fall, and I think well, if I wait and get this, what does this component do for the system, and what becomes redundant? What does this awesome desktop do for my ability to sit and use a new macbook air when I travel  or sit on the couch in my PJs?
    If there was a place that plainly stated "if you buy the new dektop you can configure a system including only these components and achieve <this result> and by adding <additional components> you will achieve this result.
    I have been to the genius store a few times, but I come out of there more confused unless I have SPECIFIC questions or already know what to buy. 
    A "System Configuration App" would be a really great sales tool--Just saying.

    I have no idea what "fully optimized" means.
    No Apple device will let you watch broadcast TV. The Apple TV is a good option for watching streaming TV from iTunes, NetFlix and Hulu. If you want to watch from other sources, you may need to look at other devices.
    Any Mac computer or iPad will allow you to surf the web.
    What business software?
    Time Capsule is a good option for back ups.
    Update what across all devices?
    For accessing documents from all devices, a service like Dropbox is your best bet.
    I have no idea what "step as far away from an internet provider as possible" means. If you want Internet access, you need an Internet provider.
    Lighting fast speed for what? Processor? The specs are listed for all devices in the Online Store. Internet? We're back to the service provider.
    Technology changes. The only way to keep pace with it beyond a couple of years is to buy new stuff.
    The bottom line is you need to look at the specs for devices availble and at your budget and decide what best meets your needs. If you are unable to do that on your own, there are lot of technology consultants out there who will, for a fee, look at your exact situation, make recommendations and even handle the purchase and set up. Perhaps that would be the best route for you.
    Best of luck.

  • I need help getting new authorization codes for digital copies

    I need help getting new authorization codes for digital copies of movies. Can someone help me out?

    There's a lot of results in Google when you search for this but unfortunately refreshing the page doesn't seem to generate a different code anymore. Mine also says already redeemed

  • Need help opening new software application Adobe Elements 12 on my new MAC. HELP?

    Need help opening new software application Adobe Elements 12 on my new MAC. HELP?

    Is it installed? If so, go to Applications and choose either Adobe Elements 12 Organizer, or Adobe Photoshop Elements 12>Support Files>Photoshop Elements Editor.

  • Need help getting new printer hp deskjet 3520 setup for eprint and wireless

    need help getting new printer hp deskjet 23520 stup for eprint and wireless

    Hi Pastorlee7,
    I see that you're having problems setting up your printer.  I would take a look at the document below.
    Hp deskjet 3520
    Let me know how it goes.  

  • Need Help Understanding How To Use iMessage Between Two iPhones

    I have an iPhone 4 and my wife an iPhone 3GS.  We both have iOS 5, but I have discovered something about iMessage I need to make sure I understand correctly.  As I understand it iMessage can send text even if our voice carrier service is unavailable.  I tend to loose signal inside the building I work in.  I usually can get texts in and out, but sometimes not.  But in testing the two phones sending iMessages, I've noticed is that if I have one of the phones with iMessage turned on and the other with iMessage turned off, the two phones will not be able to exchange text.  Is that how it's supposed to work?  Even though one of these phones can receive an iMessage doesn't mean the other one send one back.  Can't the system detect when one phone is connected and another one not, and the one that is not gets sent SMS messages instead?  I don't want to try to send my wife an iMessage because I can't get a voice signal in my building, but her have iMessages turned off and not able to get any messages from me, iMessage or SMS.  I guess I need help better understanding how this actually works between the two phones so I can always get texts back and forth between my wife and I.  My other misgiving is that this iMessage thing consumes my data limit.  My wife gets unlimited because she had her phone before the limits were imposed, but I got on board after, so I am hesitant to use iMessage all the time because of it.  I have no intention to send picture mail through iMessage, but the thing is if I wanted to switch to SMS to send picture mail to save data, but my wife's phone is set to iMessage, she won't get it.  If this is how this thing is supposed to work, I'm not really impressed.  Some insight would be appreciated

    I think you are making this way too complicated. Why are you turning iMessage off? If you are at your office connect to the WiFi there and send your wife messages that way (unless your office is blocking the port iMessage uses). When possible the two phones will use iMessage but will revert to SMS is iMessage is not available if that option is set that way.
    I would not worry about using up your data plan if you have the 2GB, text iMessages are going to be very small and MMS (picture) ones are not very large either. Unless you are sending hundreds of picture iMessages a day you will have a hard time using up your data.
    If you are near an Apple Store you should explore signing up for an intro iPhone course and have them run through iMessage options.

  • Need help with new itouch

    Please bare with me, while I 'try' to explain.
    I have my itunes account linked to my iphone and macbook. I have bought my daughter an itouch for Xmas. Now I have set up a seperate itunes account for her on my other Windows laptop. So she is able to purchase apps without them going and clogging up my itunes... NOW this is the bit i need help with...
    How can i transfer any music i have on my itunes to her itunes? and vice versa?
    Thanks in advance

    Right, I have now gone down the line of setting up a new user on my macbook, her own ID and then with the help of Mr google, I followed the steps of sharing my music, by moving my itunes media folder to a shared folder.
    Now i got my music on her itunes libary but when i did a test download of an app, it wont show in the library. I have even done the 'transfer purchases'. and its still not showing. I am slowing loosing the will to live with it! I really need help.

  • NEED Help Importing new Activities.

    Hi All,
    I am working on a project where I have been asked to add two new activities to all the 841 WBS codes belonging to the project. That means I have to add around 1600 new activities. So instead of going through the tedious task of adding those manually, I was wondering if there was an easier way like importing from Excel or anything else to do this. I need to finish this within this week, so I need help urgently.
    Please Help

    You can absolutely add new activities in via Excel import however how much easier this ultimately is depends on the structure of your project (ActIds, Codes, Relationships, etc) and the underlying data to be added.
    In a large project I have some exposure to Excel is used frequently to make activity level additions/changes, but the schedulers spent a decent amount of time early in the project re-naming activity ID's for grouping purposes (I believe specifically to help with excel imports).
    If your additions to each WBS follow any sort of consistent pattern then it may be quicker to use Excel. Even if it ends up not saving much time initially, at the very least you will have a process down for the next time you need to make major changes to your schedule.

  • Need help with new url address

    i'm very new to iweb and .mac - i've worked with websites before but never actually registered for a domain and need help setting up my iweb or .mac website with a new address.
    Can someone please help me with this...prices? where do i go? i just don't want to create a site for our student ministry at church without having a web/myname.com address.
    Thanks in advance!
    Chris

    You'll find there are a lot of good ones. Godaddy is one that I used to use. I am very happy with bluehost.com great prices and excellent service
    Produce | Shoot | Edit
    Take Two Visual Media
    http://www.take2vm.com

  • Need help buying new hard drive

    I have a macbook that needs a new hard drive and need help knowing what hard drives to buy that will be compatible with it. It is a macbook pro 17inch model no: A1297.
    Any help would be appreciated, Thanks

    Any 2.5" diameter, 9.5mm thick SATA drive will be compatible.  Currently they come up to 1.5 TB in capacity.  I have a 1 TB Seagate SSHD (hybrid) drive installed in my primary MBP.  The cost is a modest premium over a conventional HDD of the same capacity.  Boot and shutdown times are significantly faster when compared to a conventional HDD,  I can recommend this as an option.
    If the bank account permits, an SSD will produce the overall maximum performance gains.  Boot, shutdown and resource hungry applications will be noticeably faster.  Casualyll use such as e-mails and text editing will produce no meaningful performance differences compared to a conventional HDD.
    I am of the opinion that the cost premium is still too high for the benefits that they afford.  Other have different views.
    Ciao.

  • Forgot email and password. Need help! Newer mind g...

    Hello i need to get back my skype account and i dont know wich of my email is on that account becouse its been few years when i created account. Is it possible by using login nick name get back my account. For proof its my account i can tell ewerything what is on it. Please help!
    Newer mind got it back...

    Here are Two Ways to help you get your Gmail back click on both for the Info:  http://goo.gl/T9ot6   http://goo.gl/N6Ba0  b33

  • [Athlon64] Noob needs help optimizing new system

    Sorry to post yet another thread, but I've been lurking for the past few days and I only get bits and pieces of what I need. I'm pretty clueless about this stuff as it's my first home-built system
    See my sig for system info...
    I'm needing help with bios settings. The pertinent stuff (I think - hopefully I got it all down):
    CELL MENU
    CPU Clock speed: 2200
    DDR Memory Freq: 100.0 MHz
    High performance mode: Manual
    Cool n quiet: Disable
    HT Freq: 800 MHz
    Dynamic overclocking: Disable
    Adjust CPU Ratio: Auto
    AGP Freq: By Default
    HT Voltage: Auto
    Mem voltage: Auto
    CPU voltage: Auto
    AGP Voltage: Auto
    Spread sectrum: Disable
    DRAM
    DRAM Clock Mode: Manual
    Mem clock value: DDR200
    CAS Latency: SPD
    Burst Length: 8 Beat
    Bank Interleaving: Auto
    Active to CMD (Trcd): SPD
    Active to precharge (Tras): SPD
    Precharge to active (Tvp): SPD
    DRAM IT Timing: Disable
    ADVANCED CHIPSET FEATURES
    AGP Mode: Auto (this is "greyed out")
    AGP Fast write: Enabled
    AGP Aperture size: 128
    VLink 8X supported: Enabled
    My questions mainly concern memory. I bought all this stuff at the Tiger Direct outlet store in Naperville, Illinois. I had intended to buy the K8T Neo-FSR (754 pin), but they were supposedly out of the 754 pin 3400+, and this board/CPU combo had a $100 rebate. Yeah, it's one of those deals with the odd 939 pin 3400+ that everyone has been talking about.
    In any case, I already had the Corsair CMX512-3200C2PT picked out, as Corsair said it was compatible with the board. I wasn't aware of the MSI compitibility chart until I came here later that night. I STILL can't find that chart off of the MSI web site.
    Anyway, I got it all hooked up and got the standard 4 red LEDs. Not knowing what to do, I took it back to Tiger Direct and the tech played around with it until he stuck an el-cheapo stick (Corsair VS512MB400) in there and it worked. But it only works in slot 2. So here I am.
    I started to run memtest86, but it took too long to run and I aborted it for now. For what it's worth, it said the RAM CAS value is 2.5-2-2-5. I don't know what the hell that means, but I know it's important.
    My questions:
    1. I assume I need manually to set my memory clock value to DDR400?
    2. Now that I can get the thing to post, is there any chance I could get the "good" Corsair memory to work by setting the correct latency/CAS values? Again, I don't know what I'm talking about, so forgive my ignorance. What I'm wondering is if I can set everything to what Corsair recommends while I have the cheap memory in there and then replace it with the good stuff?
    3. With this board, am I better off with double-sided or single-sided sticks? As I said, I went into the store intending to buy the Neo 754-pin board, but they were out of the Athlon 3400+ in 754 and only had the 939 pin.
    4. Anything else in my bios settings that stand out and need to be addressed? I want to make sure everything is optimized.
    EDIT: I almost forgot: My CPU temp is runing around 42-49 degrees. Am I in the danger zone? I just bought a generic cooler for now and intend to get a Thermalright XP-120, but I can't find it locally, so it will have to wait.
    AND FINALLY...
    I don't know if this is related to anything above, but I have been having a hell of a time getting the 6600GT to run DirectX9+ games. The latest drivers for Windows 98SE was 66.94. Yes, XP will be installed soon, but for now... It was failing on dxdiag test for Direct3d 9 and also the third DirectDraw test. I was about to give up and take it back when I discovered that a new beta driver came out today (71.84). I installed it and it passed all of the dxdiag tests. I thought I was in hawg-heaven, but when I run Call of Duty (the only DX9 game I have besides HL2), it slows to an absolute clawl. The level starts out somewhat normal at first, but quickly slows down to the point that performance can only be measured in seconds per frame! All of the patches 1.5 and 1.51 for UO have been installed, but that shouldn't make a bit of difference.
    If I don't get my CoD fix soon I'm gonna reinstall that Geforce3.
    Thanks much and sorry again for such a long post.

    Thanks everyone for the recent replies, but I started this thread almost a month ago (March 3rd), and much has changed since then.
    New PSU (see sig).
    Replaced the PNY Geforce6600GT with a eVGA 6800
    Added another stick of the Corsair Value Select 512 RAM. I didn't even bother trying to get the "primo" CMX stick to work. I just returned it.
    Went from Windows 98SE to XP Home.
    The PSU did nothing for me at all, but I suppose it's better to have some headroom in the amperage.
    The biggest performance booster was the additional 512MB of RAM. It wouldn't have done me any good in 98SE, but I was shocked at how much it helps XP. Quitting a game is almost instant now, where before it would take a good two minutes or so for XP to recover itself.
    As for games running slow, the 6800 fixed it right up. CoD absolutely screams now, as does everything else I've thrown at it (HL2, Doom 3, Far Cry). I think the 6600GT was just bad or there is a serious driver problem with the 6600GT's. Went from 3DMark03 score of around 5000 (when it didn't crash) to above 9000 now. And this was all before adding the additional RAM.
    Oh yeah, I bought a 74GB Raptor. No RAID for now though. So far I'm not real impressed with the performance. I'm running off of the VIA controller, since my board doesn't have the Promise controller. I don't see much improvement in loading times as compared to the 40GB 7200rpm Maxtor I have running on IDE1. The only time it beats the pants off the Maxtor is defragging. But there's only so much entertainment value in that.  The Sandra "file system benchmark" gave me 57 MB/s, which seems pathetic, but I've read some posts here where others are getting an identical rate.
    And I'm not too happy to discover, too late, that my overclocking capabilities are severely limited while using SATA.
    I do have one more question for now:
    When I installed the second 512MB stick, I originally had both sticks in slot 1 and 2. I ran Sandra's memory bandwidth benchmark and got a much lower score than with the single stick (around 3500 MB/s). WHen I had the sticks in 1 and 3, it jumped up to close to 6000 MB/s. Why is that? Just curious.

  • Need help understanding syntax

    Hi,
    I need some help to understand the following syntax .
    PPRAMImpl am = (PPRAMImpl)pageContext.getApplicationModule(webBean); What is this PPARAMImpl?
    I know "am " is a variable . And with pageContext.getApplicationModule(webBean) we are trying to get the AM name for that page, then why do we need to add (PPARAMImpl) before pageContext.getApplicationModule(webBean) ?
    For example in plsql , apps.testpkg.mainproc(param1,param2)
    means
    schema.packagename.procedurename(parameter1,parameter2).
    So can you explain "PPRAMImpl am = (PPRAMImpl)pageContext.getApplicationModule(webBean)" in that manner?
    pageContext.getParameter(EVENT_PARAM))
    What is this ?
    What are the possible values for EVENT_PARAM ? And by the way , I need help on setting a default value for one of my search parameters in a search region .
    Correct me If I am wrong, this is what I thought
    1. EOImpl has setters and getters for that attribute. So call the setter method in controller and set the value , if this is right then I don't know how to right the code ,can you give me some sample code ?
    or
    2. get the view object name and then set the value for that . like viewobject.setattribute('att name',att value'),if this is right then I don't know how to right the code ,can you give me some sample code ?
    Thanks
    Sri.

    Hi,
    No. These are not equal.
    pageContext.getApplicationModule(webBean) return AM of type OAApplicationModule.
    It would be fine if your variable am, is of type OAApplicationModule:
    OAApplicationModule am = pageContext.getApplicationModule(webBean) // this would be fine.
    But as you are using of type PPRAMImpl, you must have to type-cast that externally using:
    PPRAMImpl am = (PPRAMImpl)pageContext.getApplicationModule(webBean);
    If you are still not clear, then refer any java book or google for internal & external type-casting in java.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need Help with new site glitches PLEASE!!!

    I need help trouble shooting a website. The site is
    www.farrowandwatkins.com. Nav buttons on Mac they display correctly
    which is aligned at top and bottom of content to left on Home page.
    However, when viewed on PC, the buttons spread to fill the
    distance of the "Patients" Page. All the pages spread to this
    length also, but are not suppose to.
    Nav buttons have padding of 10 on bottom, except last one.
    Please help if you can

    First guess would be that there doesn't seem to be a fixed
    height or width on the cell for the 'patients' button.

  • Need help with new 8310

    Just upgraded from earlier blackberry and have two problems I need help with!
    First, in rearranging the icons my browser icon disappeared and I can't get it back even when I use the show all function.  Any ideas?
    Second, unlike my earlier blackberry, messages I sent from my office laptop are not appearing in my messages.  What setting do I need to tweak?  I like my blackberry to show all the messages sent from or received by the laptop.
    Thanks.
    Lauren

    My BB setting was to not hide sent messages, but the problem I think has to do with the settings on syncing with my computer.  Messages I send from the blackberry show up as sent - but I want the BB to match completely with the email on my computer - show every email received and every email sent.  That was how the old BB was set up.  Any ideas on what else to tweak either on the desktop or the BB?  Thanks for your help.

Maybe you are looking for