将自定义名称空间导入ASPX

时间:2020-04-01 21:35:41

标签: c# asp.net namespaces

我在命名空间内有一个加密类,该命名空间本身在.cs文件(C#)中

我想将此文件(类)导入到我的ASPX网页。我该怎么办?

我要导入的类:

UIView

想将此导入我的ASPX页面。 这两个文件(C#类文件和ASPX文件)都在同一文件夹中。

编辑:添加了代码。

// set your needed time per second, the current is 3.0 seconds
UIView.animate(withDuration: 3.0) { 
    self.mapView.centerCoordinate = annotation.coordinate
}

2 个答案:

答案 0 :(得分:0)

假设您具有如下的c#方法Test():(警告:类必须为public,函数必须为public static

namespace PasswordEncryption
{
    public static class StringCipher
    {
        public static string Test()
        {
            return "Example string";
        }
    }
}

并且还需要将此命名空间添加到aspx文件中:

<%@ Import Namespace="PasswordEncryption" %>

然后您可以像以下这样用aspx调用此函数:

<%= StringCipher.Test() %>

答案 1 :(得分:0)

最终使用DLL进行了此操作。 我已经用C#编写了函数,编译为DLL,然后将其导入。