NoWar
NoWar

Reputation: 37633

Extension method is not visible

I am thinking to create some Extension method for the thing below.

enter image description here

So I plan to see

 @item.Roles.ConvertToString(...

I created also the extancion method itself. But It is not appearing in place I need.

 @item.Roles.  Nothing what I need... :(

Any clue?

P.S.

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

            return result;
        }
    }   

Upvotes: 1

Views: 1166

Answers (3)

Mikey Mouse
Mikey Mouse

Reputation: 3088

You'll need to export the namespace of that extension method

     @using WhereeverTheNameSpaceIs

Does it show up then?

Upvotes: 2

SLaks
SLaks

Reputation: 887225

You need to import the namespace containing your extension method using the @using directive.

Upvotes: 5

recursive
recursive

Reputation: 86064

Extension methods aren't usable if you haven't imported the namespace their class is defined in.

Upvotes: 2

Related Questions