Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Visual C# Express Visual C# IndexOf

by the3factory 4/10/2008 1:58:00 AM
Visual C# Express Visual C# IndexOf
Question:

 

I have a problem with breaking tags, i have a tag called "ActualValues\DB4.Act_Speed_M1001" but i only want the part "Act_Speed_M1001"

 

how can i use IndexOf or something else in C# to take everything after the dot .

 

i hope some1 can understand my problem Stick out tongue xD

 

thx




To be a rock and not to roll..

Answer1:

Try:-

 

 

Code Snippet
Answer2:

i think this must work, but the problem is, when i try to debug he sais: 'string' does not contain a definition for 'lastIndexOf'

do you know what to do with that?

 

thx Smile




To be a rock and not to roll..
Answer3:

 

Sorry I alternate between Javascript and C# a lot.  In C# method names begin with upper case letters try:-

 

LastIndexOf

 

 




Anthony Jones - MVP ASP/ASP.NET
Answer4:

Omg -,- ok ok.. well he doesn't gives an error anymore, but I still don't got what i want Sad

 

this is a part of what i got right now:

 

StreamReader sr = new StreamReader("C:\\5030_20070803_071829_MP270.csv");

m_TagList = new List<Tag>();

string Line;

sr.ReadLine();

while ((Line = sr.ReadLine()) != null)

{

string[] LineElem = Line.Split(";".ToCharArray());

Tag T = new Tag();

T.Name = LineElem[0];

string tag = (T.Name);

int partIndex = tag.LastIndexOf('.');

string part = null;

if (partIndex > -1) part = tag.Substring(partIndex + 1);

bool TagFound = false;

foreach (Tag T2 in m_TagList)

{

if (T2.Name == T.Name)

TagFound = true;

}

if (!TagFound)

m_TagList.Add(T);

}

sr.Close();

 

he takes different out of the csv File, but all the tags start with ActualValues\DB4. but you knew that i guess..

after he takes these tags out of the csv File he puts them bag in a new csv file, but i want them without the ActualValues\DB4.

 

can you see what i'm doing wrong ?

 

thx Smile




To be a rock and not to roll..
Answer5:

 

You aren't doing anything with the part variable wich contains the value you are after.  I suspect, but I can't be sure since I don't know enough about what you are doing, that you should be doing this:-

 

Code Snippet
Answer6:
 Mr.Guns wrote:

 

I have a problem with breaking tags, i have a tag called "ActualValues\DB4.Act_Speed_M1001" but i only want the part "Act_Speed_M1001"

 

how can i use IndexOf or something else in C# to take everything after the dot .

 

i hope some1 can understand my problem xD

 

thx

 

Is this it?

 

Code Snippet
Answer7:

Tyvm, that did it Smile it now works like i wanted it. Smile

 

thank yOu Smile




To be a rock and not to roll..

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0