Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
C# Filter Syntax Example - ASPNET CSharp String Method - Sample
Description:
Here is a Filter Example that illustrates the C# Syntax in ASP.NET.
Example Webform Code:
< %@ Page Language="C#" AutoEventWireup="true" CodeFile="Filter.aspx.cs" Inherits="StringManipulation_Filter" %> < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <h1><asp:label ID="Label1" runat="server" Text="Label"></asp:label> </h1> <asp:label ID="Label2" runat="server" Text="Label"></asp:label> </div> </form> </body> </html>
Example Code Behind:
using System; using System.IO; using System.Data; using System.Text; // This example is from http://idealprogrammer.com // It shows how you can use Filter syntax in C-Sharp ASP.NET //**************************************************************************************** // Purpose: Returns a zero-based array containing a subset of a String array based on // specified filter criteria. // // Syntax: Filter (Source As String(), Match As String, Include As Boolean, _ // Compare As CompareMethod) As String() // // Source - Required - one-dimensional string array to be searched // Match - required - string to search for // Include - optional - Boolean value indicating whether to return substrings that // include or exclude Match. // Compare - optional - numeric value indicating compare method - CompareMethod.Binary // or CompareMethod.Text //**************************************************************************************** public partial class StringManipulation_Filter : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text = "Example #1: Filter(Source, Match, Include,Compare) As String"; string[] myStrings = new string[4]; myStrings[0] = "This"; myStrings[1] = "is"; myStrings[2] = "my"; myStrings[3] = "string"; string[] FilteredStrings = null; FilteredStrings = Microsoft.VisualBasic.Strings.Filter(myStrings, "is", true, Microsoft.VisualBasic.CompareMethod.Text); StringBuilder sb = new StringBuilder(); foreach (string myItem in FilteredStrings) { sb.Append(myItem + "<br />"); // Returns ["This", "Is"]. } Label2.Text = sb.ToString(); } }
Example Connection String:
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console