// Create a new dictionary of strings, with string keys. Dictionary openWith = new Dictionary(); // Add some elements to the dictionary. There are no // duplicate keys, but some of the values are duplicates. openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); // To get the TValue of rtf(TKey) Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]; // The indexer can be used to change the value associated // with a key. openWith["rtf"] = "Alamword.exe"; Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]); // The Add method throws an exception if the new key is // already in the dictionary. try { openWith.Add("txt", "winword.exe"); } catch (ArgumentException) { Console.WriteLine("An element with Key = \"txt\" already exists."); } // If a key does not exist, setting the indexer for that key // adds a new key/value pair. // method(1) The indexer throws an exception if the requested key is // not in the dictionary. try { Console.WriteLine("For key = \"tif\", value = {0}.", openWith["tif"]); } catch (KeyNotFoundException) { Console.WriteLine("Key = \"tif\" is not found."); } // method(2) When a program often has to try keys that turn out not to // be in the dictionary, TryGetValue can be a more efficient // way to retrieve values. string value = ""; if (openWith.TryGetValue("tif", out value)) { Console.WriteLine("For key = \"tif\", value = {0}.", value); } else { Console.WriteLine("Key = \"tif\" is not found."); //Console.ReadLine(); }
- Dec 26 Mon 2011 00:21
[C#] How to use Dictionary<>
- Dec 23 Fri 2011 00:37
[ASP.NET] 使用Cache的時後,要思考有可能資料庫不光後台會動到...
恩如標題講的,最近解一個Bug挺有趣的。當Bug解完以後,在我自己的本機端測試是正常的,但是放到測試機上的時候卻出問題了......./冏\ !!!!
最後發現是有兩個問題存在:
<1> 測試機上的Cache是上一個版本的,我必須要Uninstall系統,在build起來以後才會把Cache取消掉。
<2> 測試人員從DB中直接修改資料,而後台的DropList是抓取Cache中的資料,所以就沒同步更新到了,然後在真正要撈資料的時候就會出錯了.....。
-------------------------------
- Dec 20 Tue 2011 23:05
[ASP.NET] A potentially dangerous Request.Form value was detected from the client
最近在解Bug的時候遇到了這個問題。去查了一些相關的文章以後發現,這是.Net Framework 4.0以後的新功能,它幫助你在跟Server請求任何的Request的時候,都會自動地做請求驗證(ValidationRequest)。
雖然我碰的是ASP.net,但是經由資料查詢以後只要是使用到.net framework 4.0以上的版本都會使用到這個功能,不過其實我還不太懂所以就不要亂寫好了XD。但是可以得知的是利用Asp.net撰寫網站的時候,他會預設這個功能就是了。
解決的方法也蠻簡單的:
Step1:
在指定的頁面(xxx.aspx)上,多這一串東西。
- Oct 18 Tue 2011 10:12
10.07 首爾行(延世大學、新村商圈、弘益大學、弘大商圈)
前情提要:剛從梨花女大校園走過來....,在梨大和延世大學路上休息中。
------------------------------------------------------
(在往延世大學的路途中一處地下道,地下道的牆上有許多的塗鴉)
- Oct 17 Mon 2011 16:53
10.07 首爾行(梨花女子大學)
早晨的上往十里(상왕십리역)站周邊。
------------------------------------------------------
今天的行程是學院之旅,所以我花了很多時間在走路和寫日記.....,接下來會逐步用照片和當下的日記做搭配,逐步帶領大家看看首爾的大學。
-----------------------------------------