0

是否可以将同一类中不同方法的不同返回值连接到一种方法?我想要做的是我想从所有方法/函数中获取所有返回值,并且我试图将它们作为一个字符串或数字放在我的公共静态 int GenerateId() 中。

这是我的代码:

    static void Main(string[] args)
    {
        int dateofbirth;
        string name;
        string surname;
        string firstletr;


        Console.WriteLine("Please Enter your Date of Birth in next sequence: yymmdd");
        int dob = int.Parse(Console.ReadLine());
        dateofbirth = Idenity.DateOfBirth(dob);
        Console.Clear();

        Console.WriteLine("Please enter your firsletter of your name :");
        name = Console.ReadLine().ToUpper();
        Console.WriteLine("Please enter your firsletter of your surname:");
        surname = Console.ReadLine().ToUpper();

        firstletr = Idenity.FirstLetters(name, surname);
        Console.Clear();


    }

}
class Idenity
{
    int dateofbirth, x, y, z;
    string name, surname, male, female;

    public static int DateOfBirth(int dateofbirth)
    {
        int FirstSixDigits = dateofbirth;

        return FirstSixDigits; //6
    }
    public static string FirstLetters(string name, string surname)
    {
        Dictionary<string, int> firstletters = new Dictionary<string, int>();
        firstletters.Add("A", 1);
        firstletters.Add("B", 2);
        firstletters.Add("C", 3); 
        firstletters.Add("D", 4);
        firstletters.Add("E", 5);
        firstletters.Add("F", 6);
        firstletters.Add("G", 7);
        firstletters.Add("H", 8);
        firstletters.Add("I", 9);
        firstletters.Add("J", 10);
        firstletters.Add("K", 11);
        firstletters.Add("L", 12);
        firstletters.Add("M", 13);
        firstletters.Add("N", 14);
        firstletters.Add("O", 15);
        firstletters.Add("P", 16);
        firstletters.Add("Q", 17);
        firstletters.Add("R", 18);
        firstletters.Add("S", 19);
        firstletters.Add("T", 20);
        firstletters.Add("U", 21);
        firstletters.Add("V", 22);
        firstletters.Add("W", 23);
        firstletters.Add("X", 24);
        firstletters.Add("Y", 25);
        firstletters.Add("Z", 26);

        int valueFirstletters = int.Parse(firstletters[name].ToString() + firstletters[surname].ToString());


        return valueFirstletters.ToString();//3

    }
    public static string Gender(string male, string female)
    {
        Dictionary<string, int> gender = new Dictionary<string, int>();
            gender.Add("M", 1);
            gender.Add("F", 2);
            int valueGender = 0;

            if (male == "M")
            {
                valueGender = gender[male];
                return valueGender.ToString();
            }
            else
            {
                valueGender = gender[female];
                return valueGender.ToString();
            }//1


        }

    public static int Randomize(int x, int y, int z)
    {
        Random first = new Random();
        x = first.Next(0,9);
        Random second = new Random();
        y = second.Next(0, 9);
        Random third = new Random();
        z = third.Next(0, 9);

        int valueRandomize = int.Parse(x.ToString() + y.ToString() + z.ToString());

        return valueRandomize;//3

    }
    public static int GenerateId()
    {
        int IDNumber = 0;
        IDNumber = DateOfBirth(dateofbirth);
    }

}

}

4

0 回答 0