小编kev*_*vin的帖子

使用for循环生成密码

我正在创建一个生成随机数的密码生成器,然后我使用ascii将其转换为一个字母.在for循环中,我需要字母来转换字符串而不是列表.它可以工作,但它只是将随机字母显示为列表.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

class MainClass
{
    static void Main()
    {
        int x = 1;
        int length;
        string a = "Press any key to continue";
        object num;


        while (x == 1)

        {
            Console.WriteLine("How many Characters would you like the Password to be? (Press -1 to Stop)");
            length = Convert.ToInt32(Console.ReadLine());
            try
            {
                for (int i = 0; i < length; i++)
                {
                    int num1 = Number();
                    Int32 ASCII = num1;
                    num = (char)num1;

                    if …
Run Code Online (Sandbox Code Playgroud)

c#

6
推荐指数
3
解决办法
1432
查看次数

标签 统计

c# ×1