Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在另一个类库中调用静态方法_C# - Fatal编程技术网

C# 在另一个类库中调用静态方法

C# 在另一个类库中调用静态方法,c#,C#,如何在另一个类库中调用静态方法?因为我创建了2个公共类库和另一个调用DAL,并且我已经在我的DAL类库中添加了Commmon dll引用,之后我无法找到我的方法名。难道没有别的办法解决吗 类库:通用 using System; namespace Common { public class Log { public static bool Error(Exception ex) {

如何在另一个类库中调用静态方法?因为我创建了2个公共类库和另一个调用DAL,并且我已经在我的DAL类库中添加了Commmon dll引用,之后我无法找到我的方法名。难道没有别的办法解决吗

类库:通用

using System;

    namespace Common
    {
        public class Log
        {
            public static bool Error(Exception ex)
            {
                return true;
            }
        }
    }
类库:DAL

using Common
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class MenuD
    {
        Log.;
    }
}

不能从类中的该位置调用方法之外的
Log.Error()
方法

MenuD
类中的方法中调用它

public class MenuD
{
    public void SomeMethod()
    {
        try
        {
            // do something that could throw an exception
        }
        catch (Exception ex)
        {
            var isLogged = Log.Error(ex);
        }
    }
}

正确,我的错误是忘记打开一个函数并调用它。