2011/02/25 09:53

C# 'this' keyword - Extension Method


(* over .NET Framework 3.5)

ref url. http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx

this 키워드를 통해 기존에 존재하는 Object의 Static 메소드를 추가한 것 처럼 만들 수 있다.

public static class ScottGuExtensions
{
    
public static bool IsValidEmailAddress(this string s)
    {
        Regex regex 
= new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$");
        return 
regex.IsMatch(s);
    
}
}




스캇 구슬희 형님의 VS에서 인텔리센스 되는 모습..

저작자 표시 비영리 변경 금지
크리에이티브 커먼즈 라이선스
Creative Commons License

'.NET > C#' 카테고리의 다른 글

C# - Diroctory Copy (Recursive method)  (0) 2011/03/29
Q&A - Send a None exist email with SmtpClient(C#)  (0) 2011/03/27
C# 'this' keyword - Extension Method  (0) 2011/02/25
Last.fm API and Facebook API for .NET  (0) 2010/11/01
Windows Service Debugging  (0) 2009/10/21
Unicode 한글 코드 표  (0) 2009/09/27
올블로그추천버튼 블코추천버튼 블로그뉴스추천버튼 믹시추천버튼 한RSS추가버튼 구글리더기추천버튼


이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^


Trackback 0 Comment 0

Trackback : http://i-ruru.com/trackback/644 관련글 쓰기