Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Question About Filling C# Array

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
computerstreber
Asked:
computerstreber
1 Solution
 
computerstreberAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now