1

I am developing an app from a pre-written project. While building the solution I get this error:

;expected on line 9 column 45

The VS IDE gives a red underline to the "=>" on line 9.

I am using Visual Studio 2008. I don't understand where the fault is.

Here is my code:

    using System;
    using System.Net;
    using Newtonsoft.Json.Linq;

    namespace Main.Tools
    {
        internal static class Blockr
        {
            private static string BlockrAddress => "http://btc.blockr.io/api/v1/";
            internal static double GetPrice()
            {
                var request = BlockrAddress + "coin/info/";
            var client = new WebClient();
            var result = client.DownloadString(request);

            var json = JObject.Parse(result);
            var status = json["status"];
            if ((status != null && status.ToString() == "error"))
            {
                throw new Exception(json.ToString());
            }

            return json["data"]["markets"]["coinbase"].Value<double>("value");
        }

        internal static double GetBalanceBtc(string address)
        {
            var request = BlockrAddress + "address/balance/" + address;
            var client = new WebClient();
            var result = client.DownloadString(request);

            var json = JObject.Parse(result);
            var status = json["status"];
            if ((status != null && status.ToString() == "error"))
            {
                throw new Exception(json.ToString());
            }

            return json["data"].Value<double>("balance");
            }
        }
    }
codersl
  • 2,222
  • 4
  • 30
  • 33
Praveen Yadav
  • 443
  • 4
  • 16

3 Answers3

5

On line 9 you have

private static string BlockrAddress => "http://btc.blockr.io/api/v1/";

This type of property defination is a c# 6 feature and unsupported in vs 2008. Change it to

private static string BlockrAddress {
    get { return "http://btc.blockr.io/api/v1/"; }
}
Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83
4

this is C#6 Syntax (expression bodied member), only available since Visual Studio 2015:

private static string BlockrAddress => "http://btc.blockr.io/api/v1/";

change this to:

private static string BlockrAddress get { return "http://btc.blockr.io/api/v1/" }; //property

or

private static readonly string BlockrAddress = "http://btc.blockr.io/api/v1/"; //field

and it should solve the issue

Community
  • 1
  • 1
earloc
  • 2,070
  • 12
  • 20
3

Just put private static string BlockrAddress = "http://btc.blockr.io/api/v1/"; instead of private static string BlockrAddress => "http://btc.blockr.io/api/v1/";

borkovski
  • 938
  • 8
  • 12