小编Rat*_*tus的帖子

你如何在 C#/csharp 中返回 2 个变量?

参考方法WutHap(抱歉,我没有写注释),我需要同时返回 intagg和 int sub 才能获得Main 中的NumGenintagg和 sub上的方法。我知道您可以使用数组和元组,但我在使用时遇到了麻烦。如果您需要更多上下文,请询问需要澄清的内容。我很愚蠢,所以说它需要更多的上下文可能不会导致实际的澄清。是的,我知道代码很糟糕,但这不是重点。

class Program
    {
        static void Main(string[] args)
        {
            int agg = 50;
            int sub = 50;
            for (int i = 0; i < 100; i++)
            {
                WutHap(agg, sub);
            }
            int pop = sub + agg;
            Console.WriteLine("Total aggs = " + agg);
            Console.WriteLine("Total subs = " + sub);
            Console.WriteLine("Total population = " + pop);
            Console.ReadKey();
        }
        static string NumGen()
        {
            string[] pengs = new string[2]{"agg", "sub"}; …
Run Code Online (Sandbox Code Playgroud)

c# arrays variables methods tuples

2
推荐指数
1
解决办法
3334
查看次数

标签 统计

arrays ×1

c# ×1

methods ×1

tuples ×1

variables ×1