This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Utility | |
{ | |
public static class ExtensionMethod | |
{ | |
public static int DaysOfThisMonth(this DateTime datetime) | |
{ | |
return (datetime.AddMonths(1) - datetime).Days; | |
} | |
public static bool IsImageFile(this IEnumerable<string> list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Protected Sub cancel_btn_Click(sender As Object, e As EventArgs) Handles cancel_btn.Click | |
Dim i As Integer = 0 | |
Dim j As Integer = 12 | |
tb1.Text = Str(i + j) | |
ScriptManager.RegisterClientScriptBlock(Me, GetType(String), "", "<script>$.unblockUI();</script>", False) | |
End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.dotblogs.com.tw/code6421/archive/2012/12/03/85339.aspx | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Text; | |
namespace SimpleImpl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// GrandFather 的摘要描述 | |
/// </summary> | |
public class GrandFather : System.Web.UI.Page | |
{ | |
protected virtual int GetExpireMinutes() | |
{ | |
return 480; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(len(xxx)>= 0) | |
{ | |
if(xxx != "offline" && xxx != "") | |
{ | |
//xxx非"offine",且xxx非"" | |
} | |
else if(xxx=="offline") | |
{ | |
//xxx為"offline" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myCollection = this.GetMyData(); | |
var myResult = myCollection.Select(x=> x+ ","); | |
var result= new StringBuilder(); | |
foreach(var item in myResult) | |
{ | |
result.Append(item) ; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is a second, rarer refactoring game. | |
Identify indirection that isn't paying for itself and take it out. | |
Often this takes the form of intermediate methods that used to serve a purpose but no longer do. | |
Or it could be a component that you expected to be shared or polymorphic but turned out to be used in only one place. | |
When you find parasitic indirection, take it out. | |
Again, you will have a more valuable program, | |
not because there is more of one of the four qualities listed earlier but | |
because it costs less indirection to get the same amount from the qualities. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
IList<CellPhone> o = new CellPhones(); | |
o.Add(new CellPhone()); | |
Console.WriteLine("item count:{0}", o.Count.ToString()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//這段程式碼,在4.0裡面會出錯,在3.5不會出錯。 | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var o = new OrderedDictionary(); | |
for (int i = 0; i < 3; i++) | |
{ | |
o.Add(i, string.Format("{0}_{1}", i.ToString(), "yahoo")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var list = new List<Customer>(); | |
list.Add(new Customer() { Name = "jordan", Age = 19 }); | |
list.Add(new Customer() { Name = "小章", Age = 20 }); | |
list.Add(new Customer() { Name = "盧克", Age = 34 }); | |
list.Add(new Customer() { Name = "9gy", Age = 29 }); | |
list.Add(new Customer() { Name = "小盧克", Age = 17 }); |