Re: String and Class
- From: RB <owmdkbqzikigpu@xxxxxxxxxxxxxx>
- Date: Tue, 18 Sep 2007 13:24:43 +0100
shapper wrote:
Hello,
I have a class, named MyClass, with 2 properties: Name and Text.
And I have a string as follows: "dog, new york, france , car"
Note that the words are separated by commas and that sometimes there
are spaces before and after a comma.
I want to get all words, i.e. "dog", "new york", "france" and "car",
and add them to a generic.list(of MyClass) assigning them to property
"Text".
How can I do this?
Thanks,
Miguel
Something like this (note, untested code, may not compile!
Assuming VB .Net...
Dim myList As ArrayList
Dim myString As String = "dog, new york, france , car"
Dim mySplitStringArray As String() = myString.Split(",")
Dim myTempString As String
Dim i As Integer
For Each myTempString In mySplitStringArray
MyClass o = new MyClass()
MyClass.Text = myTempString.Trim()
mylist.Add(MyClass)
Next
Hope that helps,
RB.
.
- Follow-Ups:
- Re: String and Class
- From: Phil H
- Re: String and Class
- References:
- String and Class
- From: shapper
- String and Class
- Prev by Date: Re: Validation
- Next by Date: Re: does ExecutionTimeout include file upload time?
- Previous by thread: String and Class
- Next by thread: Re: String and Class
- Index(es):
Relevant Pages
|