我怎么称呼我的价值? [英] How do I call my value?
本文介绍了我怎么称呼我的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要访问underw值,例如open,low等。
在主程序program.cs中我想引用这个值。
它是什么错了?
我尝试过:
I need acess to the beloww value for example open, low so on.
In main program program.cs I want to reference to this value.
What it's wrong?
What I have tried:
<pre lang="c#">
/* Data.cs*/
public class TimeSeries
{
public TimeSeries()
{ }
[JsonProperty(PropertyName = "1. open")]
public string Open { get; set; }
[JsonProperty(PropertyName = "2. high")]
public string High { get; set; }
[JsonProperty(PropertyName = "3. low")]
public string Low { get; set; }
[JsonProperty(PropertyName = "4. close")]
public string Close { get; set; }
[JsonProperty(PropertyName = "5. volume")]
public string Volume { get; set; }
}
public string Acess() // here it is red underline
{
this.High = H;
return this.High;
}
/*Program.cs in main program I'd like to something like this high-low*/
推荐答案
简单:它不在课堂内:
Simple: it's not inside a class:
public class TimeSeries
{
...
}
public string Acess() // here it is red underline
{
this.High = H;
return this.High;
}
C#中的所有东西都必须属于一个类!
尝试移动紧密的大括号:
Everything in C# has to be part of a class!
Try just moving the close curly bracket:
public class TimeSeries
{
public TimeSeries()
{ }
[JsonProperty(PropertyName = "1. open")]
public string Open { get; set; }
[JsonProperty(PropertyName = "2. high")]
public string High { get; set; }
[JsonProperty(PropertyName = "3. low")]
public string Low { get; set; }
[JsonProperty(PropertyName = "4. close")]
public string Close { get; set; }
[JsonProperty(PropertyName = "5. volume")]
public string Volume { get; set; }
public string Acess()
{
this.High = H;
return this.High;
}
}
读取错误窗格上的错误消息,或者将鼠标悬停在红线上会告诉你这个...
Reading the error message on the Errors pane, or by hovering over the red line would have told you this...
这篇关于我怎么称呼我的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文