我一直在閱讀SharePoint 2010的工作,我注意到,我從書籍到教學視頻中遇到的很多代碼示例都以我從未知道存在於C#中的方式投射SharePoint對象(並且認爲它是VB獨佔的) :使用「As」投射而不是(<T>)?
SPWeb web = properties.Feature.Parent as SPWeb;
我習慣了鑄造這種方式(SPWeb)properties.Feature.Parent
(VB外),如果有任何特別的原因,大多數作品在SharePoint上我遇到使用VB式的鑄造符號只是好奇。
這個問題確實與Sharepoint無關,你可能想重新標記。我添加了C#標籤。 – driis 2012-02-09 21:34:17
謝謝,這是我見過的唯一一個彈出窗口,所以我認爲這只是SharePoint的最佳實踐。 – EHorodyski 2012-02-09 21:37:51
http:// stackoverflow。com/questions/496096/cast-vs-using-the-as-keyword-in-the-clr :) – 2012-02-09 21:44:41