Question: I have some class `Item` which contains a field

```
public const string Root = "/homepage";

```

Unfortunately, it turns out this string is not a const!

When I try redefine as say

```
public string Root = DoSomething("/homepage");

```

or a property

```
public string Root
{
   get {
      return DoSomething("/homepage");
    }
}

```

I get clobbered by two different types of errors

```
A field initializer cannot reference the non-static field, method, or property 'Item.Root'

```

and this one, which i think might be a bigger problem

```
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

```

I'm not really sure how to work around this, without a serious refactoring exercise. Any advice?

Answer: 
It looks like your code has been using this `const` in static context, i.e. from a static method or a static property. This means that the replacement property must be `static` as well:

```
public static string Root = DoSomething("/homepage");

```

Of course, this implies that `DoSomething(string)` must be made static as well.

> 
> An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
> 
> 
> 

Unfortunately, you are stuck here: this error cannot be fixed, because attribute arguments must be constants. You need to reference the documentation of your specific attribute to see if there is a way to add "a level of indirection", and make the user of the attribute perform an additional request at run-time to let you provide a computed value.
This is because you are using Root as a static property. Item.Root means you are accessing Root from the class "Item" and not an object of instance type "Item".

If you need it accessible from the class itself then make Root to be static. 

If however you have an instance of Item and also accessing Root, then use your object - 

```
myItemObject.Root

```

Also do you want "DoSomething()" to execute everytime you call root in the following? Because if you make Root as static then you'll only get the first time DoSomething runs. Static property with a getter will be needed if you need it running all the time

```
public string Root = DoSomething("/homepage");

```