[英]VS2013 C# function declaration => sign
This code gives me error in vs2013 ... I don't now why ... somebody can help me ?! 这段代码在vs2013中给了我错误...我现在不知道为什么......有人可以帮助我吗? my problem is i don't know what the =>
is meant 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);
}
}
}
In this case, the =>
is denoting an expression-bodied member 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. 但是,这种语法是在C#6中引入的,它需要Visual Studio 2015编译器或更新版本。 Switch to the method syntax or upgrade your version of visual studio. 切换到方法语法或升级您的Visual Studio版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.