为什么我的抽象基类会出现这个编译错误? [英] Why am I getting this compilation error in my abstract base class?

查看:22
本文介绍了为什么我的抽象基类会出现这个编译错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展这个插件以供我自己使用...

我是否需要导入一些特殊的框架才能使用=>"操作符和Invoke"方法?这是一个抽象基类.我正在使用 VS2013

解决方案

?.是 C# 6 的一项功能,以及 => 运算符(用于表达式主体成员时),仅在 Visual Studio 2015 中可用.

在此处空条件运算符和此处=> 运算符

C# <6 语法:

protected virtual void OnConnectivityChanged(ConnectivityChangedEventArgs e){if (ConnectivityChanged != null)ConnectivityChanged.Invoke(this, e);}

I'm trying to extend this plugin for my own use...

https://github.com/jamesmontemagno/Xamarin.Plugins/blob/master/Connectivity/Connectivity/Connectivity.Plugin.Abstractions/BaseConnectivity.cs

But when I copy the code over to Visual Studio, I'm am getting some error.

Do I need to import some special framework in order to use the '=>' operator and 'Invoke' Method? This is an abstract base class. I am using VS2013

解决方案

?. is a feature from C# 6, and as well as the => operator (when used for expression-bodied members), is available in Visual Studio 2015 only.

Read about them here null-conditional operators and here => operator

C# < 6 syntax:

protected virtual void OnConnectivityChanged(ConnectivityChangedEventArgs e)
{
    if (ConnectivityChanged != null)
        ConnectivityChanged.Invoke(this, e);
}

这篇关于为什么我的抽象基类会出现这个编译错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆