<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ArraywithSplitMethod.aspx.cs" Inherits="tutorials_ArraywithSplitMethod" %> Using Arrays with String Split Method

Members Library
  C# Video Tutorials
Visual Studio 2008
Intro to VS 2008 Environment
My First Program
Creating Mulit-Project Solutions
Working with Strings
Contains
Length
Stringbuilder
Substring
Trim
Upper Case / Lower Case
IndexOf
Concatenation
Split
String Compare
Manipulating Text Files
Validating User Input
Creating Custom Controls
Using DateTime
Using the Windows API
.NET Forms

In Production
Automate Word with C#
Automate Excel with C#
Create PDF on the fly
Win API Calls
Using the System.Drawing Object
Get image from SQL Server
Upload image to SQL2005 database
Connecting to SQL Server

Coming this week!
Access CD Drive via API
Connecting to SQL Server 2005
Automating Excel with C#
A Custom Rounded Panel Control


JET
TECHNICAL.COM

jet tech
C Sharp Video Tutorials Online
all skill levels
member news
videos
sample code
C# On Demand!

Using Arrays with the String Split Method

Sometimes you need to get portions of a string. By breaking it apart using a split method, we can find portions of the string. This can be done using a portion of the string as the delimiter.

Here is a simple piece of code that uses an array and the string split() method to get the values. This is often used to find if a user entered a valid entry.

First, declare two variables. One holds the value to be checked and the other is the array that will hold the split results of the first value:

private string str = "tamurry@jettechnical.com";// <---holds the string value to be evaluated
private string[] strSplit;// <---array variable that will hold the results of string.split()

strSplit = str.Split('@'); <--split on the at symbol (@)

if(strSplit.GetLength(0) > 0) <--if the length is greater than zero, the @ symbol was found
MessageBox.Show(strSplit[0]);
else
MessageBox.Show(“Invalid email address”);<--no @ symbol means invalid email address.


Need more help on arrays? Start here...Intro to Arrays.

Let us hear your comments, send us an email.
Members Library
  Source Code Downloads
DateTime Functions
Custom Controls
Working with Strings
Working with Text Files
Validating User Input

Free Downloads
Visual Studio Express

Crystal Reports 2008
crystal reports

--MEMBER LOGIN--
email address: password:     







business broker businesses for sale