Here's one way:
string fullName = "your name";
string[] firstAndLast = fullName.Split(new char[] { ' ' });
// results:
// firstAndLast[0] == "your";
// firstAndLast[1] == "name";
--------------------
Content-Class: urn:content-classes:message
From: "rb" <r@ro.com>
Sender: "rb" <r@ro.com>
References: <N5***********************@news3.calgary.shaw.ca >
Subject: How to break on string into two seperate variable or strings in C#
Date: Wed, 30 Jul 2003 19:46:04 -0700
Lines: 16
Message-ID: <07****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcNXDeJq/ooy42iUSVawb2gRjNMrZA==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:173141
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
FA Q-----Original Message-----
Just wondering how you would break a string such as first
and last nametogether, into two separate strings or variables, each
containing thefirstName and lastName. I am a newbie at C# so any help
would be great!
Thanks
Brad
.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.