asp.net中關於雙引號和單引號的用法

來源:互聯網
上載者:User

 

(1)字串兩邊一定要加雙引號,表示這是一個字串。如上面的"abc"、"def"、"gh"兩邊的雙引號就都是表示這是一個字串。

string a="abc"+"abc";

a="abcabc";

 

(2)關於單引號',為什麼會使用單引號呢?這是因為如果發生引號嵌套,內層的雙引號就要改為單引號。

 

看例子

 

 

    <script type="text/javascript">        function abc() {            window.open('WebForm1.aspx', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');        }    </script>
        /// <summary>        /// 彈出新視窗        /// </summary>        /// <param name="pagePath">頁面路徑</param>        /// <param name="winName">新視窗名稱</param>        /// <param name="winWidth">新視窗寬度</param>        /// <param name="winHeight">新視窗高度</param>        public void openNewWin(string pagePath, string winName, int winWidth, int winHeight)        {            ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>window.open('" + pagePath + "','" + winName + "','toolbar=no,menubar=no,titlebar=no,directories=no,resizable=no,scroll=yes,status=no,fullscreen=no,center=yes,width=" + winWidth + ",height=" + winHeight + "');</script>");            return;        }

通過比較2段代碼,可以對雙引號和單引號的嵌套有一定理解

背景寫法
"<script type='text/javascript'>window.open('" + pagePath + "','" + winName + "','toolbar=no,menubar=no,titlebar=no,directories=no,resizable=no,scroll=yes,status=no,fullscreen=no,center=yes,width=" + winWidth + ",height=" + winHeight + "');</script>"

前台的寫法

 

 

    <script type="text/javascript">
   
            window.open('WebForm1.aspx', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');

 

    </script>

 

 

1.雙引號內雙引號,要用單引號表示

2.雙引號內的參數字串'" + pagePath + "'這種樣式,其他類型的是" + winWidth + "。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.