获取表单属性`不能显式调用运算符或访问器` [英] get form proterty `cannot explicitly call operator or accessor`

查看:29
本文介绍了获取表单属性`不能显式调用运算符或访问器`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 wp7 制作一个小应用程序,当我尝试从参考资料中获取时出现错误.

I'm makeing a small app for wp7, and I'm haveing an error when I try to get from a reference.

代码如下:

   private void refreshExistingShellTile()
    {
        using (IEnumerator<ShellTile> enumerator = ShellTile.get_ActiveTiles().GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ShellTile current = enumerator.get_Current();
                if (null != current.get_NavigationUri() && !current.get_NavigationUri().ToString().Equals("/"))
                {
                    Black_n_Gold.Entities.Tile tile = App.CurrentApp.tileService.findById(App.CurrentApp.tileService.getTileId(current.get_NavigationUri().ToString()));
                    if (tile != null && tile.id == this.customizedTile.id)
                    {
                        current.Delete();
                        this.createShellTile(this.customizedTile);
                    }
                }
            }
        }
    } 

我有这个错误:

'Microsoft.Phone.Shell.ShellTile.ActiveTiles.get': cannot explicitly call operator or accessor
'Microsoft.Phone.Shell.ShellTile.NavigationUri.get': cannot explicitly call operator or accessor
'System.Collections.Generic.IEnumerator<Microsoft.Phone.Shell.ShellTile>.Current.get': cannot explicitly call operator or accessor

当我尝试从属性添加或设置时遇到了同样的错误,我在网上查看,但找不到解决方案.

I'm having the same error when I try to add or set from a property, and I looked on the web, but I couldn't find the solution.

推荐答案

您正在使用基础方法名称.而不是这样:

You're using the underlying method names. Instead of this:

ShellTile current = enumerator.get_Current();

你想要:

ShellTile current = enumerator.Current;

等等.但是,我建议使用 foreach 循环而不是显式调用 GetEnumerator 等:

etc. However, I would also suggest using a foreach loop instead of explicitly calling GetEnumerator etc:

private void refreshExistingShellTile()
{
    foreach (ShellTile current in ShellTile.ActiveTiles)
    {
        Uri uri = current.NavigationUri;
        if (uri != null && uri.ToString() != "/")
        {
            Black_n_Gold.Entities.Tile tile = App.CurrentApp.tileService
                .findById(App.CurrentApp.tileService.getTileId(uri.ToString());
            if (tile != null && tile.id == customizedTile.id)
            {
                current.Delete();
                createShellTile(customizedTile);
            }
        }
    }
}

另请注意,.NET 命名约定会建议 findById 等应为 PascalCased:

Also note that .NET naming conventions would suggest that findById etc should be PascalCased:

  • FindById
  • GetTileId
  • CreateShellTile

这篇关于获取表单属性`不能显式调用运算符或访问器`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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