ERROR与每种方法的VOID字! :“期望的类,委托,枚举,接口或结构” ....请紧急请回复请尽快帮助 [英] ERROR with VOID word of each method!!! : "expected class, delegate, enum, interface, or struct" .... PLEASE URGENT PLEASE REPLY QUICKLY PLEASE HELP

查看:53
本文介绍了ERROR与每种方法的VOID字! :“期望的类,委托,枚举,接口或结构” ....请紧急请回复请尽快帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Net;

使用System.Windows;

使用System.Windows.Controls;

使用System.Windows.Navigation;

使用Microsoft .Phone.Controls;

使用Microsoft.Phone.Shell;

使用Bg_Audio_Player.Resources;

使用Microsoft.Phone.BackgroundAudio;



$
名称空间Bg_Audio_Player

{

    public void Instance_PlayStateChanged(object sender,EventArgs e)

{

   开关(BackgroundAudioPlayer.Instance.PlayerState)

    {

     案件PlayState.Playing:

        playButton.Content =" pause"; $
       休息;



      case PlayState.Paused:

      case PlayState.Stopped:

        playButton.Content =" play";

       休息;

    }


    if(null!= BackgroundAudioPlayer.Instance.Track)

    {

      txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +

                             "通过" +

                              BackgroundAudioPlayer.Instance.Track.Artist;

    }
}

    protected override void OnNavigatedTo(NavigationEventArgs e)

{

    if(PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)

    {

        playButton.Content =" pause"; $
        txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +

                         "通过" +

                          BackgroundAudioPlayer.Instance.Track.Artist;



    }¥b $ b   否则

    {

        playButton.Content =" play";

        txtCurrentTrack.Text ="" ;;

    }
}

}

    public partial class MainPage:PhoneApplicationPage

    {

       公共事件EventHandler Instance_PlayStateChanged;

        //构造函数

        public MainPage()

        {

            BackgroundAudioPlayer.Instance.PlayStateChanged + = new EventHandler(Instance_PlayStateChanged);



            //本地化ApplicationBar的示例代码

            // BuildLocalizedApplicationBar();

        }


        //构建本地化ApplicationBar的示例代码

        // private void BuildLocalizedApplicationBar()

        // {

        //    //将页面的ApplicationBar设置为ApplicationBar的新实例。

        //    ApplicationBar = new ApplicationBar();
$


        //    //创建一个新按钮,并将文本值设置为AppResources中的本地化字符串。

        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri(" /Assets/AppBar/appbar.add.rest.png",UriKind.Relative));

        //    appBarButton.Text = AppResources.AppBarButtonText;

        //    ApplicationBar.Buttons.Add(appBarButton);
$


        //    //使用AppResources中的本地化字符串创建一个新菜单项。

        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);

        //    ApplicationBar.MenuItems.Add(appBarMenuItem);

        //}

        #region按钮单击事件处理程序



        private void prevButton_Click(object sender,RoutedEventArgs e)

        {

            BackgroundAudioPlayer.Instance.SkipPrevious();

        }


        private void playButton_Click(object sender,RoutedEventArgs e)

        {

            if(PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)

            {

                BackgroundAudioPlayer.Instance.Pause();

            }¥b $ b           否则

            {

                BackgroundAudioPlayer.Instance.Play();

            }¥b $ b        }


        private void nextButton_Click(object sender,RoutedEventArgs e)

        {

            BackgroundAudioPlayer.Instance.SkipNext();

        }


        #endregion按钮单击事件处理程序



    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Bg_Audio_Player.Resources;
using Microsoft.Phone.BackgroundAudio;


namespace Bg_Audio_Player
{
    public void Instance_PlayStateChanged(object sender, EventArgs e)
{
    switch (BackgroundAudioPlayer.Instance.PlayerState)
    {
      case PlayState.Playing:
        playButton.Content = "pause";
        break;

      case PlayState.Paused:
      case PlayState.Stopped:
        playButton.Content = "play";
        break;
    }

    if (null != BackgroundAudioPlayer.Instance.Track)
    {
      txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +
                             " by " +
                             BackgroundAudioPlayer.Instance.Track.Artist;
    }
}
    protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
    {
        playButton.Content = "pause";
        txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +
                         " by " +
                         BackgroundAudioPlayer.Instance.Track.Artist;

    }
    else
    {
        playButton.Content = "play";
        txtCurrentTrack.Text = "";
    }
}
}
    public partial class MainPage : PhoneApplicationPage
    {
        public event EventHandler Instance_PlayStateChanged;
        // Constructor
        public MainPage()
        {
            BackgroundAudioPlayer.Instance.PlayStateChanged += new EventHandler(Instance_PlayStateChanged);

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
        #region Button Click Event Handlers

        private void prevButton_Click(object sender, RoutedEventArgs e)
        {
            BackgroundAudioPlayer.Instance.SkipPrevious();
        }

        private void playButton_Click(object sender, RoutedEventArgs e)
        {
            if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
            {
                BackgroundAudioPlayer.Instance.Pause();
            }
            else
            {
                BackgroundAudioPlayer.Instance.Play();
            }
        }

        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            BackgroundAudioPlayer.Instance.SkipNext();
        }

        #endregion Button Click Event Handlers

    }

推荐答案

您可以使用"插入代码"页面上的图标,用于将代码添加到邮件中,使其更易于阅读。

You can use the "insert code" icon on your pages to add the code to the message and make it easier to read.

您遇到的问题是您缺少"公共类", "公共部分类",在命名空间行和函数定义之后的行。

The problem you have is you are missing a "public class," "public partial class," etc. line after the namespace line and your function definitions.

参见下面的示例。

using System;

命名空间someApp

namespace someApp

{

公共类myclass
{
public static void somefunction()
{
做一点事();
}
/ *此处的所有其他功能... * /

public class myclass { public static void somefunction() { do_something(); } /* all your other functions in here... */

}
}





这篇关于ERROR与每种方法的VOID字! :“期望的类,委托,枚举,接口或结构” ....请紧急请回复请尽快帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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