Solved

Question About Filling C# Array

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now