티스토리 뷰
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EmptyMvcApplication.Models
{
public class DefaultClass
{
public void DefaultClassMethod()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EmptyMvcApplication.Models
{
public static class DefaultClassExtension
{
public static void DefaultClassExtentionMethod(this DefaultClass dc, string param)
{
}
}
}
확장 메서드 호출
또다른 예
using System.Linq; using System.Text; using System; namespace CustomExtensions { //Extension methods must be defined in a static class public static class StringExtension { // This is the extension method. // The first parameter takes the "this" modifier // and specifies the type for which the method is defined. public static int WordCount(this String str) { return str.Split(new char[] {' ', '.','?'}, StringSplitOptions.RemoveEmptyEntries).Length; } } } namespace Extension_Methods_Simple { //Import the extension method namespace. using CustomExtensions; class Program { static void Main(string[] args) { string s = "The quick brown fox jumped over the lazy dog."; // Call the method as if it were an // instance method on the type. Note that the first // parameter is not specified by the calling code. int i = s.WordCount(); System.Console.WriteLine("Word count of s is {0}", i); } } }
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- nl2br
- 명령어
- Task
- async
- 앱 스토어
- 특정 문자를 기준으로 자르기
- 진수 변환
- hyper-v
- System.Diagnostics
- MainActor
- await
- 아이폰
- trim
- system.io
- 상품 등록
- 공백제거
- App Store
- 문자 자르기
- html tag
- FileUpload
- In App Purchase
- .submit()
- mssql
- 제품 등록
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
글 보관함