Question: I have a following a function combination(). It returns a numpy array 'r'. In this 2D array has first column should be float. It returns it as string. It tried to convert column to float in following way. 

```
RV = np.array([[0.23, 2.5 , 5.  , 7.1],['a', 'b'],['a1', 'a2']])

def combination():
    global r 
    r = np.array(np.meshgrid(*RV)).T.reshape(-1,len(RV)) 
    return r

combination()
print(r)

r[:,0] = r[:,0].astype(float) #convert string column to float
print(r)

```

Answer: 
The IUrlHelper is not injectable by default. 

You will have to modify your startup.cs code a bit as [explained in this blog.](https://benfoster.io/blog/injecting-urlhelper-in-aspnet-core-mvc)

You will have to first register IActionContextAccessor. 

Then with the help of UrlHelperFactory, you can inject your custom implementation as shown below:

```
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
services.AddScoped<IUrlHelper>(x => {
    var actionContext = x.GetRequiredService<IActionContextAccessor>().ActionContext;
    var factory = x.GetRequiredService<IUrlHelperFactory>();
    return factory.GetUrlHelper(actionContext);
});

```

Both `IActionContextAccessor` and `IUrlHelperFactory` live in the `Microsoft.AspNetCore.Mvc.Core` package. 

If you're using the `Microsoft.AspNetCore.All` metapackage you should have this referenced already.

This should help you to resolve your problem.
Can you not just brute force some flexibility into your solution with string concatenation like this:

```
public string SlugUrl(string slug, string url, bool tilde = false)
{
    if (tilde) then
    {
        return Url.Content("~" + slug + url);
    }
    else
    {
        return Url.Content(slug + url);
    }
}

```

[...]

```
string slug1 = "www.mysite.com";
string slug2 = "www.mysite.com/Slug";
string trailUrl = "/scripts/site.js";
string result1 = SomeClass.SlugUrl(slug1, trailUrl);
string result2 = SomeClass.SlugUrl(slug2, trailUrl);
string result3 = SomeClass.SlugUrl(slug1, trailUrl, true);
string result4 = SomeClass.SlugUrl(slug2, trailUrl, true);

```

etc...