Solved

Question About Filling C# Array

Posted on 2009-04-04
1
159 Views
Last Modified: 2012-05-06
I have an application that will automatically generate a password between the lengths of 22 and 24. I need to generate two passwords. I started off by just generating them and then writing them to the console. However, I would like to save them to an array. However, the current code I have is not working. I get the following error at run time:

Array creation must have array size or array initializer.
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
 
public class Entry
{
    [STAThread]
    static void Main(string[] args)
    {
        string[][] SqlPasswords = new string[][];
 
        for (int i = 0; i < 2; i++)
            GeneratePassword.Generate(22,24).ToString();
            //Console.WriteLine(GeneratePassword.Generate(22, 24));
 
        Console.ReadLine();
    }
}

Open in new window

0
Comment
Question by:computerstreber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
computerstreber earned 0 total points
ID: 24070180
I fixed it:
public class Entry
{    
    [STAThread]
    static void Main(string[] args)
    {
        string[] SqlPasswords = new string[2];
 
        for (int i = 0; i < 2; i++)
            SqlPasswords[i] = GeneratePassword.Generate(22,24).ToString();
            //Console.WriteLine(GeneratePassword.Generate(22, 24));
 
        foreach (string SqlPassword in SqlPasswords)
        {
            Console.WriteLine("SQL Password: " + SqlPassword);
        }
 
        Console.ReadLine();
    }
}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Linq Select From List 3 139
Need to sort columns in DataGridView 4 64
Build a string of emails from a gridview 2 31
C# LINQ 5 43
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question