Solved

Question About Filling C# Array

Posted on 2009-04-04
1
161 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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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