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)
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)
// 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)
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)
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)
// 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)
恩如標題講的,最近解一個Bug挺有趣的。當Bug解完以後,在我自己的本機端測試是正常的,但是放到測試機上的時候卻出問題了......./冏\ !!!!
最後發現是有兩個問題存在:
<1> 測試機上的Cache是上一個版本的,我必須要Uninstall系統,在build起來以後才會把Cache取消掉。
<2> 測試人員從DB中直接修改資料,而後台的DropList是抓取Cache中的資料,所以就沒同步更新到了,然後在真正要撈資料的時候就會出錯了.....。
imagefish 發表在 痞客邦 留言(0) 人氣(29)
最近在解Bug的時候遇到了這個問題。去查了一些相關的文章以後發現,這是.Net Framework 4.0以後的新功能,它幫助你在跟Server請求任何的Request的時候,都會自動地做請求驗證(ValidationRequest)。
雖然我碰的是ASP.net,但是經由資料查詢以後只要是使用到.net framework 4.0以上的版本都會使用到這個功能,不過其實我還不太懂所以就不要亂寫好了XD。但是可以得知的是利用Asp.net撰寫網站的時候,他會預設這個功能就是了。
解決的方法也蠻簡單的:
Step1:
imagefish 發表在 痞客邦 留言(0) 人氣(117)
前情提要:剛從梨花女大校園走過來....,在梨大和延世大學路上休息中。
------------------------------------------------------
imagefish 發表在 痞客邦 留言(0) 人氣(1,211)

早晨的上往十里(상왕십리역)站周邊。------------------------------------------------------今天的行程是學院之旅,所以我花了很多時間在走路和寫日記.....,接下來會逐步用照片和當下的日記做搭配,逐步帶領大家看看首爾的大學。imagefish 發表在 痞客邦 留言(0) 人氣(267)