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-Sharp Filter Example - Filter - Sample Code
Description:
Illustrates the C# Syntax for Filter.
Example Class Main:
using System; public class clsFilter { public void Main() { //**************************************************************************************** // 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 //**************************************************************************************** Console.WriteLine("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); foreach (string myItem in FilteredStrings) { Console.WriteLine(myItem); // Returns ["This", "Is"]. } //write blank line to make output easier to read Console.WriteLine(); //Prevent console from closing before you press enter Console.ReadLine(); } }
Example Class Program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSharp_Syntax { class Program { static void Main(string[] args) { clsFilter myFilter = new clsFilter(); myFilter.Main(); } } }
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console