PIXNET Logo登入

幻想魚的幻想空間

跳到主文

O.O 隨手寫寫

部落格全站分類:生活綜合

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 1月 15 週日 201222:35
  • [C# 3.0] Type Parameter Assumption

Main Function
namespace ConsoleGenericsAssumption
{
class Program
{
static void Main(string[] args)
{
GenericTypeResolverTest v = new GenericTypeResolverTest("Hello Alam");
//v.Value = "Hello ALam";
v.ShowInConsole();
// -----same result, differnet implementation---
Console.WriteLine("-----same result, differnet implementation---");
string showString = v.ToString();
Console.WriteLine("{0}", showString);
Console.ReadLine();

// generic for string
string ValueString = "Hello Yaya";
ValueString.ShowInConsole();

// generic for int
int ValueInt = 12345;
ValueInt.ShowInConsole();
}
}
}
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(19)

  • 個人分類:C# 技術文章
▲top
  • 1月 09 週一 201200:54
  • [C#] What's different of [], List and ArrayList.

static void Main(string[] args)
{
// [] is specific type and fixed length.
// It is a data structure.
String[] arr = new string[] {"Hi", "I", "am", "ALam"};
ShowMessage(arr);

// List is specific type and unbounded length.
// namespace is System.Collection.Generic
List list = new List();
list.Add("Hi");
list.Add("I");
list.Add("am");
list.Add("Alam");
ShowMessage(list);

// ArrayList is any type and undounded length.
// namespace is System.Collection
ArrayList arraylist = new ArrayList();
arraylist.Add("Hi");
arraylist.Add("I");
arraylist.Add("am");
arraylist.Add("Alam");
arraylist.Add(12345); // when we call the ShowMessage, it will be wrong.
ShowMessage(arraylist);
}

private static void ShowMessage(string[] temp)
{
foreach (string aaa in temp)
{
Console.WriteLine("{0}", aaa);
}
Console.ReadLine();
}

private static void ShowMessage(List temp)
{
foreach (string aaa in temp)
{
Console.WriteLine("{0}", aaa);
}
Console.ReadLine();
}

private static void ShowMessage(ArrayList temp)
{
foreach (string aaa in temp)
{
Console.WriteLine("{0}", aaa);
}
Console.ReadLine();
}
}
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(45)

  • 個人分類:C# 技術文章
▲top
  • 1月 08 週日 201223:29
  • [C#] access stored procedure by linq

// to associates a stored procedure which user defined in the database.
// Must write it before func.
[global::System.Data.Linq.Mapping.FunctionAttribute(Name ="stored procedure name")]
// Undertake on a code, we make a func. let user to access the stored procedure.
// When SP exist input variables, you must use "Linq.Mapping.ParameterAttribute" to
// select the variable in DB and use "System.Nullable" to set
// what variable you wnat to assign in code.
public int storedProcedureForC#Class(
[global::System.Data.Linq.Mapping.ParameterAttribute(Name:"inputVarName",
DbType="inputVarType"] System.Nullable varInC#)
{
// Execute the stored procedure.
IExecuteResult objectForSP = this.ExecuteMethodCall(this, (
(MethodInfo)(MethodInfo.GetCurrentMethod())), varInC#);
return ((int)(result.ReturnValue));
}
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(120)

  • 個人分類:C# 技術文章
▲top
  • 1月 04 週三 201222:55
  • [C#] Specific Symbol"as" is used in Session of asp.net

So........We know "as" is a powerful method that perform certain types of conversions between compatible reference types. for example:
 
// ...... //
Array[] = dataTable;
// ....do something for dataTable.//
const string = "ALamTest";
Session[ALamTest] = dataTable;

//....do another something...//

Array[] getTable = Session[AlamTest] as Array[]
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(18)

  • 個人分類:C# 技術文章
▲top
  • 12月 31 週六 201122:22
  • [C#] Extension method for C#3.0

This is a new Characteristic in C#3.0
namespace ConsoleUseExtensionMethod
{
public static class TestExtensionConsumer
{
public static void Main()
{
var s = "AlamInGamania";
// Extension Method
Console.WriteLine(s.WordCount());
Console.WriteLine("{0}{1}","效果同上",WordCount(s));
Console.ReadLine();
}

///summary
/// NonGenerics and must use static class
///summary
///<input> the input type is that want to extend </input>
///<return>the length of string</return>
public static int WordCount(this string v)
{
return v.Length; // Please "Note" Input parameter that The keyword "this".
}
}

}
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:C# 技術文章
▲top
  • 12月 26 週一 201100:21
  • [C#] How to use Dictionary<>


// 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();
}
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:C# 技術文章
▲top
  • 12月 23 週五 201100:37
  • [ASP.NET] 使用Cache的時後,要思考有可能資料庫不光後台會動到...

恩如標題講的,最近解一個Bug挺有趣的。當Bug解完以後,在我自己的本機端測試是正常的,但是放到測試機上的時候卻出問題了......./冏\ !!!!
最後發現是有兩個問題存在:
<1> 測試機上的Cache是上一個版本的,我必須要Uninstall系統,在build起來以後才會把Cache取消掉。
<2> 測試人員從DB中直接修改資料,而後台的DropList是抓取Cache中的資料,所以就沒同步更新到了,然後在真正要撈資料的時候就會出錯了.....。
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(29)

  • 個人分類:ASP.NET 經驗分享
▲top
  • 12月 20 週二 201123: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:
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(117)

  • 個人分類:ASP.NET 經驗分享
▲top
  • 10月 18 週二 201110:12
  • 10.07 首爾行(延世大學、新村商圈、弘益大學、弘大商圈)

IMG_0034.JPG前情提要:剛從梨花女大校園走過來....,在梨大和延世大學路上休息中。
------------------------------------------------------
 
 
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(1,211)

  • 個人分類:旅遊
▲top
  • 10月 17 週一 201116:53
  • 10.07 首爾行(梨花女子大學)

IMG_0001.JPGIMG_0001.JPG  
早晨的上往十里(상왕십리역)站周邊。
------------------------------------------------------
今天的行程是學院之旅,所以我花了很多時間在走路和寫日記.....,接下來會逐步用照片和當下的日記做搭配,逐步帶領大家看看首爾的大學。
(繼續閱讀...)
文章標籤

imagefish 發表在 痞客邦 留言(0) 人氣(267)

  • 個人分類:旅遊
▲top
«1...3458»

個人頭像

imagefish
暱稱:
imagefish
分類:
生活綜合
好友:
累積中
地區:

近期文章

  • [C#] HTML Agility Pack 相關
  • [C#] Convert Json to C# DataStruct by JSON.NET library
  • [NoSQL] 安裝時卡點的問題。
  • [NoSQL] Hadoop on Ubuntu
  • C# 與 ReportingService2005 互動的方法
  • [C#] C# 讀取 Excel file 相關資料
  • [NoSQL] The Introduction of Hadoop
  • [DB] Collation設定:Case Sensitive && Case Insensitive
  • [ASP.NET] 利用VSPerfMon做出 Code coverage的報告(上) (實測ASP.NET可用)
  • 杰倫與女貴族

文章彙整

文章分類

  • NoSQL (3)
  • Relation-DB (1)
  • ASP.NET 經驗分享 (9)
  • C# 技術文章 (22)
  • 旅遊 (9)
  • 英文 (1)
  • 樂曲創作&&音樂欣賞 (3)
  • 棒球相關 (10)
  • 科技討論 (6)
  • 碎碎念 (11)
  • 未分類文章 (1)

部落格文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: