无法从另一个类调用方法。 C#

时间:2017-11-24 23:52:48

标签: c#

你好我试着在不同的类中调用一个方法,所以当用户选择按钮1时它会调用

它表示方法myMethod没有重载需要0个参数

images = tf.placeholder(tf.float32, shape=[None, 32, 32, 3])
gray_images = tf.image.rgb_to_grayscale(images)  # has shape (None, 32, 32, 1)

1 个答案:

答案 0 :(得分:-1)

使用System;

命名空间废话 {     class firstClass     {         public static void Main(string [] args)         {                 int choice = 0;

        while (choice != 1 && choice != 2)

            {

            Console.WriteLine ("Press 1 for choice 1 or 2 for choice for choice 2");
            choice = Convert.ToInt32 (Console.ReadLine ());

            if (choice == 1) {
                crap.secondClass.myMethod();
            }
            if (choice == 2) {

            }

        }
    }
}

public class secondClass{

    public static void myMethod()
    {

        Console.WriteLine("You chose option 1");

    }
}

}