System.Convert.ToDouble(ushort)

Here are the examples of the csharp api System.Convert.ToDouble(ushort) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

19 Source : CharAdvancedConverter.cs
with MIT License
from DataObjects-NET

double IAdvancedConverter<char, double>.Convert(char value)
    {
      return System.Convert.ToDouble(System.Convert.ToUInt16(value));
    }

19 Source : UInt16AdvancedConverter.cs
with MIT License
from DataObjects-NET

double IAdvancedConverter<ushort, double>.Convert(ushort value)
    {
      return System.Convert.ToDouble(value);
    }

19 Source : BasicConvert.Overload.cs
with MIT License
from Dogwei

double IXConverter<ushort, double>.Convert(ushort value)
			=> Convert.ToDouble(value);

19 Source : DataExtraction.cs
with MIT License
from mahalex

public static double[] UshortToDouble(ushort[] source)
        {
            var result = new double[source.Length];
            for (var i = 0; i < source.Length; i++)
            {
                result[i] = Convert.ToDouble(source[i]);
            }

            return result;
        }

19 Source : UInt16Extensions.cs
with GNU General Public License v3.0
from ME3Tweaks

public static double ToDouble(this ushort value)
		{
			return Convert.ToDouble(value);
		}

19 Source : NumericConverter.cs
with MIT License
from MudBlazor

private double OnSet(T arg)
        {
            if (arg == null)
                return double.NaN; // <-- this catches all nullable values which are null. no nullchecks necessary below!
            try
            {
                // double
                if (typeof(T) == typeof(double))
                    return (double)(object)arg;
                else if (typeof(T) == typeof(double?))
                    return ((double?)(object)arg).Value;
                // string
                if (typeof(T) == typeof(string))
                    return double.Parse((string)(object)arg, NumberStyles.Any, Culture);
                // sbyte
                if (typeof(T) == typeof(sbyte))
                    return Convert.ToDouble((sbyte)(object)arg);
                if (typeof(T) == typeof(sbyte?))
                    return Convert.ToDouble(((sbyte?)(object)arg).Value);
                // byte
                if (typeof(T) == typeof(byte))
                    return Convert.ToDouble((byte)(object)arg);
                if (typeof(T) == typeof(byte?))
                    return Convert.ToDouble(((byte?)(object)arg).Value);
                // short
                if (typeof(T) == typeof(short))
                    return Convert.ToDouble((short)(object)arg);
                if (typeof(T) == typeof(short?))
                    return Convert.ToDouble(((short?)(object)arg).Value);
                // ushort
                if (typeof(T) == typeof(ushort))
                    return Convert.ToDouble((ushort)(object)arg);
                if (typeof(T) == typeof(ushort?))
                    return Convert.ToDouble(((ushort?)(object)arg).Value);
                // int
                else if (typeof(T) == typeof(int))
                    return Convert.ToDouble((int)(object)arg);
                else if (typeof(T) == typeof(int?))
                    return Convert.ToDouble(((int?)(object)arg).Value);
                // uint
                else if (typeof(T) == typeof(uint))
                    return Convert.ToDouble((uint)(object)arg);
                else if (typeof(T) == typeof(uint?))
                    return Convert.ToDouble(((uint?)(object)arg).Value);
                // long
                else if (typeof(T) == typeof(long))
                    return Convert.ToDouble((long)(object)arg);
                else if (typeof(T) == typeof(long?))
                    return Convert.ToDouble(((long?)(object)arg).Value);
                // ulong
                else if (typeof(T) == typeof(ulong))
                    return Convert.ToDouble((ulong)(object)arg);
                else if (typeof(T) == typeof(ulong?))
                    return Convert.ToDouble(((ulong?)(object)arg).Value);
                // float
                else if (typeof(T) == typeof(float))
                    return Convert.ToDouble((float)(object)arg);
                else if (typeof(T) == typeof(float?))
                    return Convert.ToDouble(((float?)(object)arg).Value);
                // decimal
                else if (typeof(T) == typeof(decimal))
                    return Convert.ToDouble((decimal)(object)arg);
                else if (typeof(T) == typeof(decimal?))
                    return Convert.ToDouble(((decimal?)(object)arg).Value);
                else
                {
                    UpdateSetError("Unable to convert to double from type " + typeof(T).Name);
                    return double.NaN;
                }
            }
            catch (FormatException e)
            {
                UpdateSetError("Conversion error: " + e.Message);
                return double.NaN;
            }
        }

19 Source : NumericConverter.cs
with MIT License
from MudBlazor

public static double From<T>(T v)
        {
            if (typeof(T) == typeof(sbyte))
                return Convert.ToDouble((sbyte)(object)v);
            if (typeof(T) == typeof(byte))
                return Convert.ToDouble((byte)(object)v);
            if (typeof(T) == typeof(short))
                return Convert.ToDouble((short)(object)v);
            if (typeof(T) == typeof(ushort))
                return Convert.ToDouble((ushort)(object)v);
            if (typeof(T) == typeof(int))
                return Convert.ToDouble((int)(object)v);
            if (typeof(T) == typeof(uint))
                return Convert.ToDouble((uint)(object)v);
            if (typeof(T) == typeof(long))
                return Convert.ToDouble((long)(object)v);
            if (typeof(T) == typeof(ulong))
                return Convert.ToDouble((ulong)(object)v);
            if (typeof(T) == typeof(float))
                return Convert.ToDouble((float)(object)v);
            if (typeof(T) == typeof(double))
                return Convert.ToDouble((double)(object)v);
            if (typeof(T) == typeof(decimal))
                return Convert.ToDouble((decimal)(object)v);
            if (typeof(T) == typeof(sbyte?))
                return Convert.ToDouble((sbyte?)(object)v);
            if (typeof(T) == typeof(byte?))
                return Convert.ToDouble((byte?)(object)v);
            if (typeof(T) == typeof(short?))
                return Convert.ToDouble((short?)(object)v);
            if (typeof(T) == typeof(ushort?))
                return Convert.ToDouble((ushort?)(object)v);
            if (typeof(T) == typeof(int?))
                return Convert.ToDouble((int?)(object)v);
            if (typeof(T) == typeof(uint?))
                return Convert.ToDouble((uint?)(object)v);
            if (typeof(T) == typeof(long?))
                return Convert.ToDouble((long?)(object)v);
            if (typeof(T) == typeof(ulong?))
                return Convert.ToDouble((ulong?)(object)v);
            if (typeof(T) == typeof(float?))
                return Convert.ToDouble((float?)(object)v);
            if (typeof(T) == typeof(double?))
                return Convert.ToDouble((double?)(object)v);
            if (typeof(T) == typeof(decimal?))
                return Convert.ToDouble((decimal?)(object)v);
            return default;
        }

19 Source : UShortConvertor.cs
with GNU General Public License v3.0
from SeeSharpOpenSource

protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => System.Convert.ToDecimal((ushort)sourceValue));
            ConvertFuncs.Add(typeof(double).Name, sourceValue => System.Convert.ToDouble((ushort)sourceValue));
            ConvertFuncs.Add(typeof(float).Name, sourceValue => System.Convert.ToSingle((ushort)sourceValue));
            ConvertFuncs.Add(typeof(long).Name, sourceValue => System.Convert.ToInt64((ushort)sourceValue));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => System.Convert.ToUInt64((ushort)sourceValue));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => System.Convert.ToInt32((ushort)sourceValue));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => System.Convert.ToUInt32((ushort)sourceValue));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => System.Convert.ToInt16((ushort)sourceValue));
//            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => System.Convert.ToUInt16((ushort)sourceValue));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => System.Convert.ToChar((ushort)sourceValue));
            ConvertFuncs.Add(typeof(byte).Name, sourceValue => System.Convert.ToByte((ushort)sourceValue));
            ConvertFuncs.Add(typeof(bool).Name, sourceValue => (ushort)sourceValue > 0);
            ConvertFuncs.Add(typeof(string).Name, sourceValue => sourceValue.ToString());
        }

19 Source : UInt16.cs
with MIT License
from Team-RTCLI

double IConvertible.ToDouble(IFormatProvider? provider)
        {
            return Convert.ToDouble(m_value);
        }