Solved

Question About Filling C# Array

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Allow users to select all checkboxes 6 60
C# Update Status Bar.... 1 24
c# if statement weird reaction 3 30
XAML: Layout 8 0
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

12 Experts available now in Live!

Get 1:1 Help Now