Solved

Question About Filling C# Array

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 78
Web Form VB.Net  import CSV 4 39
Keyboard 2 34
Cant save 3D 4 21
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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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