小编Yos*_*srJ的帖子

无法在非静态上下文中访问静态方法

我创建了一个使用名为 GetUrl 的方法的部分视图,但出现错误cannot access static method in a non static context

以下是我如何实现该方法:

public class TimeLineStep
{
    public string Code { get; set; }
    public string Title { get; set; }
    public TimeLineStatus Status { get; set; }
    public string Description { get; set; }
    public string Category { get; set; }

    public static string GetUrl(string code)
    {
        switch (code)
        {
            case "1":
                return "#";
            case "2":
                return "#";
            case "3":
                return "#";
            case "4":
                return "#";
            case "5": …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc static-methods

2
推荐指数
1
解决办法
3888
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

c# ×1

static-methods ×1