小编The*_*Ace的帖子

'namespace'但用作'type'

这是我的程序,类使用它被称为Time2我将引用添加到TimeTest我一直得到错误'Time2'是'命名空间'但是像'类型'一样使用

有人可以告诉我这个错误是什么以及如何解决它?

namespace TimeTest
{
  class TimeTest
  {
    static void Main(string[] args)
    {
        Time2 t1 = new Time2();
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

c# namespaces class

67
推荐指数
4
解决办法
13万
查看次数

使用baseclass方法返回值?

我在我的基类中有一个方法返回一个bool,我想要那个bool来确定在我的派生类中相同的重写方法会发生什么.

基础:

    public bool Debt(double bal)
    {
        double deb = 0;
        bool worked;

        if (deb > bal)
        {
            Console.WriteLine("Debit amount exceeds the account balance – withdraw cancelled");
            worked = false;
        }
        else

        bal = bal - deb;
        worked = true;

        return worked;
    }
Run Code Online (Sandbox Code Playgroud)

派生

public override void Debt(double bal)
    {
        // if worked is true do something

    }
Run Code Online (Sandbox Code Playgroud)

请注意,bal来自我之前制作的构造函数

c# methods inheritance

6
推荐指数
1
解决办法
1918
查看次数

价值得不到正确答案

int c;
int f = 20;
c = 5 / 9 * (f - 32);
Console.WriteLine(c);
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

如果我运行此代码c最终为0,这是错误的.谁能告诉我为什么?

c#

3
推荐指数
1
解决办法
131
查看次数

在结果之间添加空格

我有以下代码和输出

for ($i=0;$i<=100;$i++)
if ($i % 2!=0)
echo $i + "";


?>
Run Code Online (Sandbox Code Playgroud)

13579111315171921232527293133353739414345474951535557596163656769717375777981838587899193959799问题是数字之间没有空格.如何添加此空间

php

-4
推荐指数
1
解决办法
77
查看次数

标签 统计

c# ×3

class ×1

inheritance ×1

methods ×1

namespaces ×1

php ×1