Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
AnswerRe: {"Invalid object name 'Table."} Pin
Richard Blythe16-Sep-08 5:16
Richard Blythe16-Sep-08 5:16 
GeneralRe: {"Invalid object name 'Table."} Pin
postonoh16-Sep-08 6:14
postonoh16-Sep-08 6:14 
GeneralRe: {"Invalid object name 'Table."} Pin
Richard Blythe16-Sep-08 7:15
Richard Blythe16-Sep-08 7:15 
QuestionNot Opening SQL Database file in Web applications: Pin
nkmnkmnkmnkm16-Sep-08 4:49
nkmnkmnkmnkm16-Sep-08 4:49 
Questionextracting sustrings from a string and store it in an array Pin
wajans16-Sep-08 3:56
wajans16-Sep-08 3:56 
AnswerRe: extracting sustrings from a string and store it in an array Pin
Alan Balkany16-Sep-08 4:04
Alan Balkany16-Sep-08 4:04 
AnswerRe: extracting sustrings from a string and store it in an array Pin
DaveyM6916-Sep-08 4:13
professionalDaveyM6916-Sep-08 4:13 
AnswerRe: extracting sustrings from a string and store it in an array [modified] Pin
#realJSOP16-Sep-08 4:15
mve#realJSOP16-Sep-08 4:15 
It would probably end up being a three-step process. If it's safe to assume that the stuff you're looking for would always be separated by a space, you could do this:

string str = "something is [!better] than [!nothing]";
// split the string on spaces
string[] parts = str.Split(' ');
List<string> resultStringList = new List<string>();

foreach (string part in parts)
{
    int pos1 = part.IndexOf("[");
    int pos2 = part.IndexOf("]");
    if (pos1 >= 0 && pos2 >= 0)
    {
        // get everything between the brackets, but NOT the brackets themselves
        string result = part.SubString(pos1+1, pos2);
        // add it to the list
        resultStringList.Add(result);
    }
}

string[] myResults = new string[resultStringList.Count];
for (int i = 0; i < resultStringList.Count; i++)
{
    myResults[i] = resultStringList[i];
}

</string></string>



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


modified on Tuesday, September 16, 2008 10:23 AM

GeneralRe: extracting sustrings from a string and store it in an array Pin
wajans16-Sep-08 19:43
wajans16-Sep-08 19:43 
AnswerRe: extracting sustrings from a string and store it in an array Pin
PIEBALDconsult16-Sep-08 4:24
mvePIEBALDconsult16-Sep-08 4:24 
AnswerRe: extracting sustrings from a string and store it in an array [modified] Pin
Guffa16-Sep-08 6:12
Guffa16-Sep-08 6:12 
GeneralRe: extracting sustrings from a string and store it in an array Pin
wajans16-Sep-08 19:31
wajans16-Sep-08 19:31 
AnswerRe: extracting sustrings from a string and store it in an array Pin
wajans16-Sep-08 20:22
wajans16-Sep-08 20:22 
GeneralRe: extracting sustrings from a string and store it in an array Pin
Guffa16-Sep-08 21:45
Guffa16-Sep-08 21:45 
GeneralRe: extracting sustrings from a string and store it in an array Pin
wajans18-Sep-08 20:55
wajans18-Sep-08 20:55 
GeneralRe: extracting sustrings from a string and store it in an array Pin
Guffa18-Sep-08 22:43
Guffa18-Sep-08 22:43 
AnswerRe: extracting sustrings from a string and store it in an array [modified] Pin
wajans18-Sep-08 23:48
wajans18-Sep-08 23:48 
GeneralRe: extracting sustrings from a string and store it in an array Pin
egenis16-Sep-08 20:29
egenis16-Sep-08 20:29 
QuestionHow to add rows into Datatable? Pin
zeeShan anSari16-Sep-08 3:34
zeeShan anSari16-Sep-08 3:34 
AnswerRe: How to add rows into Datatable? Pin
Harvey Saayman16-Sep-08 3:45
Harvey Saayman16-Sep-08 3:45 
GeneralRe: How to add rows into Datatable? Pin
zeeShan anSari16-Sep-08 3:59
zeeShan anSari16-Sep-08 3:59 
GeneralRe: How to add rows into Datatable? Pin
Harvey Saayman16-Sep-08 4:04
Harvey Saayman16-Sep-08 4:04 
GeneralRe: How to add rows into Datatable? Pin
zeeShan anSari16-Sep-08 4:06
zeeShan anSari16-Sep-08 4:06 
GeneralRe: How to add rows into Datatable? Pin
zeeShan anSari16-Sep-08 4:06
zeeShan anSari16-Sep-08 4:06 
GeneralRe: How to add rows into Datatable? Pin
Harvey Saayman16-Sep-08 4:11
Harvey Saayman16-Sep-08 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.