Please someone help me

M

mca

When I try to read tokens from a text file, c# does not
accept "-" (minus sign) as a valid token and tokenizer
always throws exception. What should I do to make "-"
sign valid

Important note : I have also tried to read "-" sign from
console environemnt but system could not define minues
sign either in console.

Looking forward your replies

Sinecerely

Can Akpinar
(e-mail address removed)
 
N

Nicholas Paldino [.NET/C# MVP]

Can,

Can you elaborate exactly how you are tokenizing the string? There is
no standard tokenizer class in .NET, so I am not sure what you are referring
to.
 
D

Doug

Have you tried String.Split("-")? For example:

string inS = "abc-def";
string sArgs = "-";

string [] sArray = inS.Split(sArgs.ToCharArray());

for(int i = 0; i < sArray.Length; i++)
{
System.Console.WriteLine("String " + i + " == \"" + sArray +
"\"");
}

Returns:

String 0 == "abc"
String 1 == "def"

doug

Nicholas Paldino said:
Can,

Can you elaborate exactly how you are tokenizing the string? There is
no standard tokenizer class in .NET, so I am not sure what you are referring
to.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mca said:
When I try to read tokens from a text file, c# does not
accept "-" (minus sign) as a valid token and tokenizer
always throws exception. What should I do to make "-"
sign valid

Important note : I have also tried to read "-" sign from
console environemnt but system could not define minues
sign either in console.

Looking forward your replies

Sinecerely

Can Akpinar
(e-mail address removed)
 
C

can akpinar

Thanks a lot for your attention !

I searched for a tokenizer in MSDN library and found a
one. I other words I am using MSDN's string tokenizer.
But porblem is not the tokenizer. As I mentioned in my
previous message, since c# can not define the "-" sign
even I try to input it from console. I mean,
Console.Readline() command also can not determine the "-"
sign.
I wonder whether there is some other syntax for minus
sign like ex:"/-" or "@-" etc. or not ..

Sincerely,

can akpinar
(e-mail address removed)
-----Original Message-----
Can,

Can you elaborate exactly how you are tokenizing the string? There is
no standard tokenizer class in .NET, so I am not sure what you are referring
to.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mca said:
When I try to read tokens from a text file, c# does not
accept "-" (minus sign) as a valid token and tokenizer
always throws exception. What should I do to make "-"
sign valid

Important note : I have also tried to read "-" sign from
console environemnt but system could not define minues
sign either in console.

Looking forward your replies

Sinecerely

Can Akpinar
(e-mail address removed)


.
 
G

Grant Richins [MS]

Are you possibly confusing a single-character string with a character
constant? C# handles "-" and '-' just fine as normal strings and characters
that can be read from the console or files.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.


can akpinar said:
Thanks a lot for your attention !

I searched for a tokenizer in MSDN library and found a
one. I other words I am using MSDN's string tokenizer.
But porblem is not the tokenizer. As I mentioned in my
previous message, since c# can not define the "-" sign
even I try to input it from console. I mean,
Console.Readline() command also can not determine the "-"
sign.
I wonder whether there is some other syntax for minus
sign like ex:"/-" or "@-" etc. or not ..

Sincerely,

can akpinar
(e-mail address removed)
-----Original Message-----
Can,

Can you elaborate exactly how you are tokenizing the string? There is
no standard tokenizer class in .NET, so I am not sure what you are referring
to.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mca said:
When I try to read tokens from a text file, c# does not
accept "-" (minus sign) as a valid token and tokenizer
always throws exception. What should I do to make "-"
sign valid

Important note : I have also tried to read "-" sign from
console environemnt but system could not define minues
sign either in console.

Looking forward your replies

Sinecerely

Can Akpinar
(e-mail address removed)


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top