私はこのようなクラスを取得しました:
namespace MYSCommon
{
[Serializable]
public class Cart
{
// Methods
public Cart(){
//Code skip
}
public double Value{
//Code skip
}
}
}
このメソッドを使用してaspxを呼び出しましたが、エラーが発生しました。
コード:
<%= MYSCommon.Cart.Value %>
エラー:
Compiler Error Message: CS0120: An object reference is required for the nonstatic field, method, or property 'MYSCommon.Cart.Value'
しかし、私はこのような別のものを手に入れました:
namespace MYSCommon
{
public class Constant
{
// Fields
public static string staticValue = "Something";
}
}
そしてそれを次のように呼びました:<%= MYSCommon.Constant.staticValue %>
、これは成功です。どうすれば解決できますか?ありがとう。