将值c#传递给类之间的函数 [英] pass value c# to the function between classes

查看:108
本文介绍了将值c#传递给类之间的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有一个基本问题,涉及在句柄之间传递值.我创建了一个计算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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆