将值c#传递给类之间的函数 [英] pass value c# to the function between classes
问题描述
你好
我有一个基本问题,涉及在句柄之间传递值.我创建了一个计算pitagoras的程序.这只是为了在C#中练习OOP(我是初学者).
I have a basic question about passing values between clases. I created a program to calculate pitagoras. This is just to practice OOP in C#(I am beginner).
问题是用于计算pitagoras的函数显示错误,并且我不确定我的错误在哪里.这是完整的程序:
The problem is the function for calculating pitagoras shows error and I am not sure where is my mistake. Here's the complete program:
这是我创建对象的主程序:
This is the main program where I created the object:
推荐答案
当您发表这样的帖子时,最好显示错误文字,以便我们知道所要查找的内容.
When you make a post like this, it is a good idea to show the text of the errors so that we know what we are looking for.
在这种情况下,我的猜测是pita()不应为静态,而应为公共.
In this case, my guess is that pita() should not be static, but should be public.
public void pita(); // Take the word "static" from this line and add "public".
{
double result = Math.Sqrt((Math.Pow(x,2)) + (Math.Pow(y,2)));
Console.WriteLine("Le resultat des valeurs est: " + result);
}
这篇关于将值c#传递给类之间的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!