2012-06-07 28 views
1

我有以下問題。我遇到了有關默認參數的錯誤。我爲過載添加了一段簡單的代碼。現在我得到新的代碼(第3行:CreatePageSection(sItemID,「」,null);)給出標題中提到的錯誤。錯誤C#.NET 3.0:爲了獲得最佳重載方法匹配「CreatePageSection(REF字符串,字符串參考,參考對象)」具有一些無效參數

我看着在其他議題的答案,但我不能發現問題。有人能幫我嗎?

的代碼這裏找到:

public void CreatePageSection(ref string sItemID) 
    { 
     CreatePageSection(sItemID, "", null); 
    } 

public void CreatePageSection(ref string sItemID, ref string sFrameUrl, ref object vOnReadyState) 
    { 

     if (Strings.InStr(msPresentPageSections, "|" + sItemID + "|", 0) > 0) { 
      return; 
     } 
     msPresentPageSections = msPresentPageSections + sItemID + "|"; 

     string writeHtml = "<div class=" + MConstants.QUOTE + "PageSection" + MConstants.QUOTE + " id=" + MConstants.QUOTE + "Section" + sItemID + "Div" + MConstants.QUOTE + " style=" + MConstants.QUOTE + "display: none;" + MConstants.QUOTE + ">"; 
     this.WriteLine_Renamed(ref writeHtml); 
     //UPGRADE_WARNING: Couldn't resolve default property of object vOnReadyState. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' 
     //UPGRADE_NOTE: IsMissing() was changed to IsNothing_Renamed(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"' 
     writeHtml = " <iframe id=" + MConstants.QUOTE + sItemID + "Frame" + MConstants.QUOTE + " name=" + MConstants.QUOTE + sItemID + "Frame" + MConstants.QUOTE + " frameborder=" + MConstants.QUOTE + "0" + MConstants.QUOTE + (!string.IsNullOrEmpty(sFrameUrl) ? " src=" + MConstants.QUOTE + sFrameUrl + MConstants.QUOTE : "") + ((vOnReadyState == null) ? "" : " onreadystatechange=" + MConstants.QUOTE + Convert.ToString(vOnReadyState) + MConstants.QUOTE) + ">"; 
     this.WriteLine_Renamed(ref writeHtml); 
     writeHtml = " </iframe>"; 
     this.WriteLine_Renamed(ref writeHtml); 
     writeHtml = "</div>"; 
     this.WriteLine_Renamed(ref writeHtml); 

    } 

回答

2

,你必須通過引用傳遞PARAMS

public void CreatePageSection(ref string sItemID) 
{ 
    var missingString = String.Empty; 
    object missingObject = null; 
    CreatePageSection(ref sItemID, ref missingString, ref missingObject); 
} 
相關問題