Member 13921752 Ответов: 1

Как я могу назвать свою ценность?


Мне нужен acess к значению beloww, например open, low и так далее.
В основной программе program.cs я хочу сослаться на это значение.
Что тут не так?

Что я уже пробовал:

<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*/

ZurdoDev

Я не понимаю вашего вопроса.

1 Ответов

Рейтинг:
11

OriginalGriff

Просто: это не внутри класса:

 public class TimeSeries
        {
...
        }

        public string Acess()   // here it is red underline
        {
            this.High = H;
            return this.High;
        }
Все в C# должно быть частью класса!

Попробуйте просто переместить близкую фигурную скобку:
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;
           }
       }
Чтение сообщения об ошибке на панели ошибок или наведение указателя мыши на красную линию сказали бы вам об этом...


Member 13921752

Действительно! Спасибо!

OriginalGriff

Всегда пожалуйста!