Alexei196 Alexei196 -4 years ago 226
C# Question

error CS0030: Cannot convert type 'void' to 'double'

The compiler gives an error CS0030: Cannot convert type 'void' to 'double'. Help me please.
The code here:

static public double Decode(string a)
{
double c=double.Parse(a);
return (double)Console.WriteLine(c%3);
}

Answer Source

Modify your function and use it like in example below.

using System;   
public class Program
{
    public static double Decode(string a)
    {    
        return double.Parse(a);
    }

    public static void Main()
    {
        var decoded = Decode("2.1");

        Console.WriteLine(decoded);
    }           
}

OUTPUT: 2.1

If you want improve this function read about Double.TryParse.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download