VS2013 function declaration C # => sign

This code is giving me an error in vs2013 ... I don't understand why ... can anyone help me? my problem is that i don't know what it is for =>

and how to fix the errors

using System;

namespace SmartStore.Core.Logging
{
    public static class LoggingExtensions
    {
        public static bool IsDebugEnabled(this ILogger l)                                               => l.IsEnabledFor(LogLevel.Debug);


    public static void Fatal(this ILogger l, string msg)                                            => FilteredLog(l, LogLevel.Fatal, null, msg, null);
    public static void Fatal(this ILogger l, Func<string> msgFactory)                               => FilteredLog(l, LogLevel.Fatal, null, msgFactory);

    public static void ErrorsAll(this ILogger logger, Exception exception)
    {
        while (exception != null)
        {
            FilteredLog(logger, LogLevel.Error, exception, exception.Message, null);
            exception = exception.InnerException;
        }
    }

    private static void FilteredLog(ILogger logger, LogLevel level, Exception exception, string message, object[] objects)
    {
        if (logger.IsEnabledFor(level))
        {
            logger.Log(level, exception, message, objects);
        }
    }

    private static void FilteredLog(ILogger logger, LogLevel level, Exception exception, Func<string> messageFactory)
    {
        if (logger.IsEnabledFor(level))
        {
            logger.Log(level, exception, messageFactory(), null);
        }
    }
}

      

+3


source to share


1 answer


In this case, =>

denotes an element with an expression-expression and is equivalent to:

public static void Fatal(this ILogger l, Func<string> msgFactory) 
{ 
    return FilteredLog(l, LogLevel.Fatal, null, msgFactory); 
}

      



However, this syntax was introduced in C # 6, which requires the Visual Studio 2015 compiler or newer. Switch to method syntax or update your version of visual studio.

+6


source







All Articles