using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DripCode.Text
{
public static class ExtensionMethods
{
public static Boolean ContainsAt(this string line, string template, int location)
{
return line.Contains(template) && line.Length >= template.Length + location && line.Substring(location, template.Length) == template;
}
}
}
Usage:
string Test = "hello world!"
Console.WriteLine(Test.ContainsAt("hello",0).ToString());
Console.WriteLine(Test.ContainsAt("world",6).ToString());
Extension Methods (C# Programming Guide)
No comments:
Post a Comment