扩展方法不可见

Dev*_*per 1 .net c# extension-methods

我想为下面的东西创建一些扩展方法.

在此输入图像描述

所以我打算看看

 @item.Roles.ConvertToString(...
Run Code Online (Sandbox Code Playgroud)

我还创建了extancion方法本身.但它并没有出现在我需要的地方.

 @item.Roles.  Nothing what I need... :(
Run Code Online (Sandbox Code Playgroud)

任何线索?

PS

 public static class MyExtensions
    {
        public static string ConvertToString(this ICollection<IdentityUserRole> identityUserRole)
        {
            var result = string.Empty;

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

SLa*_*aks 5

您需要使用该@using指令导入包含扩展方法的命名空间.