2015-05-19 27 views
-1

我想做一個程序,所以如果我的Skype的名稱/編號是大衛它不會做任何事情,但如果它的其他人Skype名稱/ ID它會改變RichMoodText我知道如何改變RichMoodText但它只是檢測如果某一協議Skype4COM C#幫助!如果skype.CurrentUserProfile.FullName =「大衛」

請幫助

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using SKYPE4COMLib; 

namespace Skype_Tools_2 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      //RMT Means RichMoodText 
      string RMT = "Hi"; 
      //CFN Means Creators FullName 
      string CFN = "David Fedrick"; 

      Skype skype = new Skype(); 
      skype.Attach(); 
      //skype.CurrentUserProfile.RichMoodText = RMT; 

      if skype.CurrentUserProfile.FullName = CFN; <---- 
      Cannot implicitly convert type 'string' to 'bool' 
     } 
    } 
} 
+1

if(skype.CurrentUserProfile.FullName.Equals(CFN))? – dbarnes

回答

2

=是賦值運算符。您應該在if語句中使用比較運算符,在這種情況下爲==。此外,該聲明應在括號內,如

if (a == b) 
{ 
    \\ do your thing 
} 
+1

最後沒有分號。 –